summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/channel.go16
-rw-r--r--app/notification.go11
-rw-r--r--model/post.go1
3 files changed, 20 insertions, 8 deletions
diff --git a/app/channel.go b/app/channel.go
index 7c14538f4..76eb4d337 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -1140,10 +1140,10 @@ func (a *App) PostAddToChannelMessage(user *model.User, addedUser *model.User, c
UserId: user.Id,
RootId: postRootId,
Props: model.StringInterface{
- "userId": user.Id,
- "username": user.Username,
- "addedUserId": addedUser.Id,
- "addedUsername": addedUser.Username,
+ "userId": user.Id,
+ "username": user.Username,
+ model.POST_PROPS_ADDED_USER_ID: addedUser.Id,
+ "addedUsername": addedUser.Username,
},
}
@@ -1162,10 +1162,10 @@ func (a *App) postAddToTeamMessage(user *model.User, addedUser *model.User, chan
UserId: user.Id,
RootId: postRootId,
Props: model.StringInterface{
- "userId": user.Id,
- "username": user.Username,
- "addedUserId": addedUser.Id,
- "addedUsername": addedUser.Username,
+ "userId": user.Id,
+ "username": user.Username,
+ model.POST_PROPS_ADDED_USER_ID: addedUser.Id,
+ "addedUsername": addedUser.Username,
},
}
diff --git a/app/notification.go b/app/notification.go
index e4ee041af..d69bb4e2e 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -89,6 +89,17 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
keywords := a.GetMentionKeywordsInChannel(profileMap, post.Type != model.POST_HEADER_CHANGE && post.Type != model.POST_PURPOSE_CHANGE)
m := GetExplicitMentions(post.Message, keywords)
+
+ // Add an implicit mention when a user is added to a channel
+ // even if the user has set 'username mentions' to false in account settings.
+ if post.Type == model.POST_ADD_TO_CHANNEL {
+ val := post.Props[model.POST_PROPS_ADDED_USER_ID]
+ if val != nil {
+ uid := val.(string)
+ m.MentionedUserIds[uid] = true
+ }
+ }
+
mentionedUserIds, hereNotification, channelNotification, allNotification = m.MentionedUserIds, m.HereMentioned, m.ChannelMentioned, m.AllMentioned
// get users that have comment thread mentions enabled
diff --git a/model/post.go b/model/post.go
index 31837b8c8..1db4b842a 100644
--- a/model/post.go
+++ b/model/post.go
@@ -49,6 +49,7 @@ const (
POST_PROPS_MAX_USER_RUNES = POST_PROPS_MAX_RUNES - 400 // Leave some room for system / pre-save modifications
POST_CUSTOM_TYPE_PREFIX = "custom_"
PROPS_ADD_CHANNEL_MEMBER = "add_channel_member"
+ POST_PROPS_ADDED_USER_ID = "addedUserId"
)
type Post struct {