summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorChristian Claus <ch.claus@me.com>2018-03-28 06:02:04 +0200
committerElias Nahum <nahumhbl@gmail.com>2018-03-28 07:02:04 +0300
commit257f74873297a6c6b4d14f2d21ffc3adad620c4c (patch)
treee4220b50c707759fb98bd2e49a765952bd705cc9 /app/notification.go
parent71c9dff7662868770f66ab876ad66b354133c2c1 (diff)
downloadchat-257f74873297a6c6b4d14f2d21ffc3adad620c4c.tar.gz
chat-257f74873297a6c6b4d14f2d21ffc3adad620c4c.tar.bz2
chat-257f74873297a6c6b4d14f2d21ffc3adad620c4c.zip
[PLT-4340] Channel Mute and "/mute" command #7617 (#7713)
* Add command and store changes to allow mute toggling * Change channel muting to use ChannelMember notification structure * Suppress email and push notifications for a muted channel * Make i18n keys issue-compliant * Add notification-cache handling for channel-muting * Add channel handle for channel-muting slash-command * Add unit test for mute command * Merge branch 'master' into PLT-4340 # Conflicts: # app/notification.go * Fix issue that command_mute responses will be overwritten * Fix i18n key for channel muting * Apply new Provider Interface to MuteCommand * Migrate mute notification property to mark_unread PLT-4340 * Make some i18n improvements for command_mute PLT-4340 * Remove de.json translations * Prevent push notifications when channel is muted * Treat Group messages like Direct messages * Fix unit test * Send WS event when the channel member notify props changed
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/notification.go b/app/notification.go
index bb0c8703f..181ad4aac 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -163,6 +163,14 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
}
}
+ // Remove the user as recipient when the user has muted the channel.
+ if channelMuted, ok := channelMemberNotifyPropsMap[id][model.MARK_UNREAD_NOTIFY_PROP]; ok {
+ if channelMuted == model.CHANNEL_MARK_UNREAD_MENTION {
+ l4g.Debug("Channel muted for user_id %v, channel_mute %v", id, channelMuted)
+ userAllowsEmails = false
+ }
+ }
+
//If email verification is required and user email is not verified don't send email.
if a.Config().EmailSettings.RequireEmailVerification && !profileMap[id].EmailVerified {
l4g.Error("Skipped sending notification email to %v, address not verified. [details: user_id=%v]", profileMap[id].Email, id)
@@ -980,6 +988,13 @@ func DoesNotifyPropsAllowPushNotification(user *model.User, channelNotifyProps m
userNotify := userNotifyProps[model.PUSH_NOTIFY_PROP]
channelNotify, ok := channelNotifyProps[model.PUSH_NOTIFY_PROP]
+ // If the channel is muted do not send push notifications
+ if channelMuted, ok := channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP]; ok {
+ if channelMuted == model.CHANNEL_MARK_UNREAD_MENTION {
+ return false
+ }
+ }
+
if post.IsSystemMessage() {
return false
}