summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-06-06 14:29:10 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-06-06 14:29:10 -0400
commitc0d1b8fbb9a141b942d73ad4869e612cdf01bbcd (patch)
tree2c1fe6dfa35bc4d9e913c3eb9aaf74e3b3a1fac6 /api
parenteabd67e4cbc845a2f591fdcf525696c0c2505d0b (diff)
downloadchat-c0d1b8fbb9a141b942d73ad4869e612cdf01bbcd.tar.gz
chat-c0d1b8fbb9a141b942d73ad4869e612cdf01bbcd.tar.bz2
chat-c0d1b8fbb9a141b942d73ad4869e612cdf01bbcd.zip
System messages trigger notifications when user is mentioned (#3235)
Diffstat (limited to 'api')
-rw-r--r--api/post.go47
1 files changed, 23 insertions, 24 deletions
diff --git a/api/post.go b/api/post.go
index 3acbaff40..408e96377 100644
--- a/api/post.go
+++ b/api/post.go
@@ -470,28 +470,6 @@ func handleWebhookEvents(c *Context, post *model.Post, team *model.Team, channel
}
func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *model.Channel, profileMap map[string]*model.User, members []model.ChannelMember) {
- message := model.NewMessage(c.TeamId, post.ChannelId, post.UserId, model.ACTION_POSTED)
- message.Add("post", post.ToJson())
- message.Add("channel_type", channel.Type)
- message.Add("team_id", team.Id)
-
- if len(post.Filenames) != 0 {
- message.Add("otherFile", "true")
-
- for _, filename := range post.Filenames {
- ext := filepath.Ext(filename)
- if model.IsFileExtImage(ext) {
- message.Add("image", "true")
- break
- }
- }
- }
-
- if post.IsSystemMessage() {
- go Publish(message)
- return
- }
-
if _, ok := profileMap[post.UserId]; !ok {
l4g.Error(utils.T("api.post.send_notifications_and_forget.user_id.error"), post.UserId)
return
@@ -547,7 +525,9 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
keywordMap["@channel"] = append(keywordMap["@channel"], profile.Id)
}
- if profile.NotifyProps["push"] == model.USER_NOTIFY_ALL && (post.UserId != profile.Id || post.Props["from_webhook"] == "true") {
+ if profile.NotifyProps["push"] == model.USER_NOTIFY_ALL &&
+ (post.UserId != profile.Id || post.Props["from_webhook"] == "true") &&
+ !post.IsSystemMessage() {
alwaysNotifyUserIds = append(alwaysNotifyUserIds, profile.Id)
}
}
@@ -605,7 +585,9 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
mentionedUsersList := make([]string, 0, len(mentionedUserIds))
senderName := ""
- if profile, ok := profileMap[post.UserId]; ok {
+ if post.IsSystemMessage() {
+ senderName = c.T("system.message.name")
+ } else if profile, ok := profileMap[post.UserId]; ok {
senderName = profile.Username
}
@@ -647,7 +629,24 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
}
+ message := model.NewMessage(c.TeamId, post.ChannelId, post.UserId, model.ACTION_POSTED)
+ message.Add("post", post.ToJson())
+ message.Add("channel_type", channel.Type)
+ message.Add("channel_display_name", channel.DisplayName)
message.Add("sender_name", senderName)
+ message.Add("team_id", team.Id)
+
+ if len(post.Filenames) != 0 {
+ message.Add("otherFile", "true")
+
+ for _, filename := range post.Filenames {
+ ext := filepath.Ext(filename)
+ if model.IsFileExtImage(ext) {
+ message.Add("image", "true")
+ break
+ }
+ }
+ }
if len(mentionedUsersList) != 0 {
message.Add("mentions", model.ArrayToJson(mentionedUsersList))