mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Send clear push notification when DM has unread messages (#10065)
* Send clear push notification when DM has unread messages * Feedback review
This commit is contained in:
@@ -1600,6 +1600,13 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, clearPush
|
||||
channelsToClearPushNotifications := []string{}
|
||||
if *a.Config().EmailSettings.SendPushNotifications && clearPushNotifications {
|
||||
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)
|
||||
if result.Err != nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
} 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.Data.(int64) > 0 {
|
||||
count := result.Data.(int64)
|
||||
if count > 0 {
|
||||
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user