diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-08-23 08:47:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-23 08:47:25 -0400 |
commit | 065d01c121907bc5529d7019e53b93819daf85f3 (patch) | |
tree | 3496c273b7477d7cf0c4c42a95f4f4a1d94251dd /api | |
parent | c93ce7af3fc89ba3f76517245d18f55b238beb11 (diff) | |
download | chat-065d01c121907bc5529d7019e53b93819daf85f3.tar.gz chat-065d01c121907bc5529d7019e53b93819daf85f3.tar.bz2 chat-065d01c121907bc5529d7019e53b93819daf85f3.zip |
Add notification settings to control what statuses allow push notifications (#3829)
Diffstat (limited to 'api')
-rw-r--r-- | api/post.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/api/post.go b/api/post.go index b4c70fab2..984b79adf 100644 --- a/api/post.go +++ b/api/post.go @@ -565,7 +565,7 @@ func sendNotifications(teamId string, post *model.Post, team *model.Team, channe } mentionedUserIds := make(map[string]bool) - alwaysNotifyUserIds := []string{} + allActivityPushUserIds := []string{} hereNotification := false updateMentionChans := []store.StoreChannel{} @@ -629,7 +629,7 @@ func sendNotifications(teamId string, post *model.Post, team *model.Team, channe if profile.NotifyProps["push"] == model.USER_NOTIFY_ALL && (post.UserId != profile.Id || post.Props["from_webhook"] == "true") && !post.IsSystemMessage() { - alwaysNotifyUserIds = append(alwaysNotifyUserIds, profile.Id) + allActivityPushUserIds = append(allActivityPushUserIds, profile.Id) } } } @@ -705,13 +705,28 @@ func sendNotifications(teamId string, post *model.Post, team *model.Team, channe if sendPushNotifications { for _, id := range mentionedUsersList { - if profileMap[id].NotifyProps["push"] != "none" { + var status *model.Status + var err *model.AppError + if status, err = GetStatus(id); err != nil { + status = &model.Status{id, model.STATUS_OFFLINE, 0} + } + + if profileMap[id].StatusAllowsPushNotification(status) { sendPushNotification(post, profileMap[id], channel, senderName, true) } } - for _, id := range alwaysNotifyUserIds { + + for _, id := range allActivityPushUserIds { if _, ok := mentionedUserIds[id]; !ok { - sendPushNotification(post, profileMap[id], channel, senderName, false) + var status *model.Status + var err *model.AppError + if status, err = GetStatus(id); err != nil { + status = &model.Status{id, model.STATUS_OFFLINE, 0} + } + + if profileMap[id].StatusAllowsPushNotification(status) { + sendPushNotification(post, profileMap[id], channel, senderName, false) + } } } } |