PLT-7502 fixing clearing of push notifications for iOS (#7429)
* PLT-7502 fixing clearing of push notificaitons for iOS * PLT-7502 fixing clearing of push notificaitons for iOS
Этот коммит содержится в:
@@ -649,32 +649,39 @@ func (a *App) sendPushNotification(post *model.Post, user *model.User, channel *
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) ClearPushNotification(userId string, channelId string) *model.AppError {
|
func (a *App) ClearPushNotification(userId string, channelId string) {
|
||||||
sessions, err := a.getMobileAppSessions(userId)
|
go func() {
|
||||||
if err != nil {
|
// Sleep is to allow the read replicas a chance to fully sync
|
||||||
return err
|
// the unread count for sending an accurate count.
|
||||||
}
|
// Delaying a little doesn't hurt anything and is cheaper than
|
||||||
|
// attempting to read from master.
|
||||||
|
time.Sleep(time.Second * 5)
|
||||||
|
|
||||||
msg := model.PushNotification{}
|
sessions, err := a.getMobileAppSessions(userId)
|
||||||
msg.Type = model.PUSH_TYPE_CLEAR
|
if err != nil {
|
||||||
msg.ChannelId = channelId
|
l4g.Error(err.Error())
|
||||||
msg.ContentAvailable = 0
|
return
|
||||||
if badge := <-a.Srv.Store.User().GetUnreadCount(userId); badge.Err != nil {
|
}
|
||||||
msg.Badge = 0
|
|
||||||
l4g.Error(utils.T("store.sql_user.get_unread_count.app_error"), userId, badge.Err)
|
|
||||||
} else {
|
|
||||||
msg.Badge = int(badge.Data.(int64))
|
|
||||||
}
|
|
||||||
|
|
||||||
l4g.Debug(utils.T("api.post.send_notifications_and_forget.clear_push_notification.debug"), msg.DeviceId, msg.ChannelId)
|
msg := model.PushNotification{}
|
||||||
|
msg.Type = model.PUSH_TYPE_CLEAR
|
||||||
|
msg.ChannelId = channelId
|
||||||
|
msg.ContentAvailable = 0
|
||||||
|
if badge := <-a.Srv.Store.User().GetUnreadCount(userId); badge.Err != nil {
|
||||||
|
msg.Badge = 0
|
||||||
|
l4g.Error(utils.T("store.sql_user.get_unread_count.app_error"), userId, badge.Err)
|
||||||
|
} else {
|
||||||
|
msg.Badge = int(badge.Data.(int64))
|
||||||
|
}
|
||||||
|
|
||||||
for _, session := range sessions {
|
l4g.Debug(utils.T("api.post.send_notifications_and_forget.clear_push_notification.debug"), msg.DeviceId, msg.ChannelId)
|
||||||
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
|
||||||
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
|
||||||
go a.sendToPushProxy(tmpMessage, session)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
for _, session := range sessions {
|
||||||
|
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
|
||||||
|
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
|
||||||
|
go a.sendToPushProxy(tmpMessage, session)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) sendToPushProxy(msg model.PushNotification, session *model.Session) {
|
func (a *App) sendToPushProxy(msg model.PushNotification, session *model.Session) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user