Adding ability to remove push ids when reported as removed from google or apple (#5513)
* Adding ability to remove push device Ids when reported as removed from google or apple * Fixing log string * Removing unneeded nil check
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
8509c2f0b0
Коммит
80273d0234
@@ -514,7 +514,7 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
|
|||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
||||||
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
||||||
go sendToPushProxy(tmpMessage)
|
go sendToPushProxy(tmpMessage, session)
|
||||||
|
|
||||||
if einterfaces.GetMetricsInterface() != nil {
|
if einterfaces.GetMetricsInterface() != nil {
|
||||||
einterfaces.GetMetricsInterface().IncrementPostSentPush()
|
einterfaces.GetMetricsInterface().IncrementPostSentPush()
|
||||||
@@ -546,13 +546,13 @@ func ClearPushNotification(userId string, channelId string) *model.AppError {
|
|||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
||||||
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
||||||
go sendToPushProxy(tmpMessage)
|
go sendToPushProxy(tmpMessage, session)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendToPushProxy(msg model.PushNotification) *model.AppError {
|
func sendToPushProxy(msg model.PushNotification, session *model.Session) *model.AppError {
|
||||||
msg.ServerId = utils.CfgDiagnosticId
|
msg.ServerId = utils.CfgDiagnosticId
|
||||||
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
@@ -565,8 +565,17 @@ func sendToPushProxy(msg model.PushNotification) *model.AppError {
|
|||||||
if resp, err := httpClient.Do(request); err != nil {
|
if resp, err := httpClient.Do(request); err != nil {
|
||||||
return model.NewLocAppError("sendToPushProxy", "api.post.send_notifications_and_forget.push_notification.error", map[string]interface{}{"DeviceId": msg.DeviceId, "Error": err.Error()}, "")
|
return model.NewLocAppError("sendToPushProxy", "api.post.send_notifications_and_forget.push_notification.error", map[string]interface{}{"DeviceId": msg.DeviceId, "Error": err.Error()}, "")
|
||||||
} else {
|
} else {
|
||||||
ioutil.ReadAll(resp.Body)
|
m := model.MapFromJson(resp.Body)
|
||||||
resp.Body.Close()
|
if resp.Body != nil {
|
||||||
|
ioutil.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
if m[model.STATUS] == model.STATUS_REMOVE {
|
||||||
|
l4g.Info("Device was reported as removed for UserId=%v SessionId=%v removing push for this session", session.UserId, session.Id)
|
||||||
|
AttachDeviceId(session.Id, "", session.ExpiresAt)
|
||||||
|
ClearSessionCacheForUser(session.UserId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const (
|
|||||||
STATUS = "status"
|
STATUS = "status"
|
||||||
STATUS_OK = "OK"
|
STATUS_OK = "OK"
|
||||||
STATUS_FAIL = "FAIL"
|
STATUS_FAIL = "FAIL"
|
||||||
|
STATUS_REMOVE = "REMOVE"
|
||||||
|
|
||||||
CLIENT_DIR = "webapp/dist"
|
CLIENT_DIR = "webapp/dist"
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user