From eab6f7459478d23968466766cbe49185d405a056 Mon Sep 17 00:00:00 2001 From: David Meza Date: Tue, 30 May 2017 11:02:44 -0500 Subject: PLT-6485 Add ability to disable `@here` notifications (#6372) --- app/notification.go | 22 +++++----------------- .../user_settings/user_settings_notifications.jsx | 3 ++- webapp/i18n/en.json | 2 +- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/app/notification.go b/app/notification.go index 4efdd3d6d..49576d1f0 100644 --- a/app/notification.go +++ b/app/notification.go @@ -222,23 +222,6 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe ) } - if hereNotification { - statuses := GetAllStatuses() - for _, status := range statuses { - if status.UserId == post.UserId { - continue - } - - _, profileFound := profileMap[status.UserId] - _, alreadyMentioned := mentionedUserIds[status.UserId] - - if status.Status == model.STATUS_ONLINE && profileFound && !alreadyMentioned { - mentionedUsersList = append(mentionedUsersList, status.UserId) - updateMentionChans = append(updateMentionChans, Srv.Store.Channel().IncrementMentionCount(post.ChannelId, status.UserId)) - } - } - } - // Make sure all mention updates are complete to prevent race // Probably better to batch these DB updates in the future // MUST be completed before push notifications send @@ -790,6 +773,11 @@ func GetMentionKeywordsInChannel(profiles map[string]*model.User) map[string][]s if int64(len(profiles)) < *utils.Cfg.TeamSettings.MaxNotificationsPerChannel && profile.NotifyProps["channel"] == "true" { keywords["@channel"] = append(keywords["@channel"], profile.Id) keywords["@all"] = append(keywords["@all"], profile.Id) + + status := GetStatusFromCache(profile.Id) + if status != nil && status.Status == model.STATUS_ONLINE { + keywords["@here"] = append(keywords["@here"], profile.Id) + } } } diff --git a/webapp/components/user_settings/user_settings_notifications.jsx b/webapp/components/user_settings/user_settings_notifications.jsx index b0b4855b2..6cfceb444 100644 --- a/webapp/components/user_settings/user_settings_notifications.jsx +++ b/webapp/components/user_settings/user_settings_notifications.jsx @@ -589,7 +589,7 @@ export default class NotificationsTab extends React.Component { /> @@ -658,6 +658,7 @@ export default class NotificationsTab extends React.Component { if (this.state.channelKey) { keys.push('@channel'); keys.push('@all'); + keys.push('@here'); } if (this.state.customKeys.length > 0) { keys = keys.concat(this.state.customKeys.split(',')); diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index fe2a9ae5a..20fef3c47 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -2257,7 +2257,7 @@ "user.settings.modal.security": "Security", "user.settings.modal.title": "Account Settings", "user.settings.notifications.allActivity": "For all activity", - "user.settings.notifications.channelWide": "Channel-wide mentions \"@channel\", \"@all\"", + "user.settings.notifications.channelWide": "Channel-wide mentions \"@channel\", \"@all\", \"@here\"", "user.settings.notifications.close": "Close", "user.settings.notifications.comments": "Reply notifications", "user.settings.notifications.commentsAny": "Trigger notifications on messages in reply threads that I start or participate in", -- cgit v1.2.3-1-g7c22