Send clear push notification when DM has unread messages (#10065)
* Send clear push notification when DM has unread messages * Feedback review
Этот коммит содержится в:
@@ -1600,6 +1600,13 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, clearPush
|
|||||||
channelsToClearPushNotifications := []string{}
|
channelsToClearPushNotifications := []string{}
|
||||||
if *a.Config().EmailSettings.SendPushNotifications && clearPushNotifications {
|
if *a.Config().EmailSettings.SendPushNotifications && clearPushNotifications {
|
||||||
for _, channelId := range channelIds {
|
for _, channelId := range channelIds {
|
||||||
|
chanResult := <-a.Srv.Store.Channel().Get(channelId, true)
|
||||||
|
if chanResult.Err != nil {
|
||||||
|
mlog.Warn(fmt.Sprintf("Failed to get channel %v", chanResult.Err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
channel := chanResult.Data.(*model.Channel)
|
||||||
|
|
||||||
result := <-a.Srv.Store.Channel().GetMember(channelId, userId)
|
result := <-a.Srv.Store.Channel().GetMember(channelId, userId)
|
||||||
if result.Err != nil {
|
if result.Err != nil {
|
||||||
mlog.Warn(fmt.Sprintf("Failed to get membership %v", result.Err))
|
mlog.Warn(fmt.Sprintf("Failed to get membership %v", result.Err))
|
||||||
@@ -1618,9 +1625,10 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, clearPush
|
|||||||
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if notify == model.USER_NOTIFY_MENTION {
|
} else if notify == model.USER_NOTIFY_MENTION || channel.Type == model.CHANNEL_DIRECT {
|
||||||
if result := <-a.Srv.Store.User().GetUnreadCountForChannel(userId, channelId); result.Err == nil {
|
if result := <-a.Srv.Store.User().GetUnreadCountForChannel(userId, channelId); result.Err == nil {
|
||||||
if result.Data.(int64) > 0 {
|
count := result.Data.(int64)
|
||||||
|
if count > 0 {
|
||||||
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user