Include post_id and root_id to handle actions from the PN (#7286)

Этот коммит содержится в:
enahum
2017-08-28 11:54:23 -03:00
коммит произвёл GitHub
родитель 1709b94227
Коммит 871b7eaa66
2 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@@ -574,6 +574,8 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
msg.Type = model.PUSH_TYPE_MESSAGE msg.Type = model.PUSH_TYPE_MESSAGE
msg.TeamId = channel.TeamId msg.TeamId = channel.TeamId
msg.ChannelId = channel.Id msg.ChannelId = channel.Id
msg.PostId = post.Id
msg.RootId = post.RootId
msg.ChannelName = channel.Name msg.ChannelName = channel.Name
msg.SenderId = post.UserId msg.SenderId = post.UserId
@@ -590,15 +592,15 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
} }
if *utils.Cfg.EmailSettings.PushNotificationContents == model.FULL_NOTIFICATION { if *utils.Cfg.EmailSettings.PushNotificationContents == model.FULL_NOTIFICATION {
msg.Category = model.CATEGORY_CAN_REPLY
if channel.Type == model.CHANNEL_DIRECT { if channel.Type == model.CHANNEL_DIRECT {
msg.Category = model.CATEGORY_DM
msg.Message = senderName + ": " + model.ClearMentionTags(post.Message) msg.Message = senderName + ": " + model.ClearMentionTags(post.Message)
} else { } else {
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_in") + channelName + ": " + model.ClearMentionTags(post.Message) msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_in") + channelName + ": " + model.ClearMentionTags(post.Message)
} }
} else if *utils.Cfg.EmailSettings.PushNotificationContents == model.GENERIC_NO_CHANNEL_NOTIFICATION { } else if *utils.Cfg.EmailSettings.PushNotificationContents == model.GENERIC_NO_CHANNEL_NOTIFICATION {
if channel.Type == model.CHANNEL_DIRECT { if channel.Type == model.CHANNEL_DIRECT {
msg.Category = model.CATEGORY_DM msg.Category = model.CATEGORY_CAN_REPLY
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message") msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message")
} else if wasMentioned || channel.Type == model.CHANNEL_GROUP { } else if wasMentioned || channel.Type == model.CHANNEL_GROUP {
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention_no_channel") msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention_no_channel")
@@ -607,9 +609,10 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
} }
} else { } else {
if channel.Type == model.CHANNEL_DIRECT { if channel.Type == model.CHANNEL_DIRECT {
msg.Category = model.CATEGORY_DM msg.Category = model.CATEGORY_CAN_REPLY
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message") msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_message")
} else if wasMentioned || channel.Type == model.CHANNEL_GROUP { } else if wasMentioned || channel.Type == model.CHANNEL_GROUP {
msg.Category = model.CATEGORY_CAN_REPLY
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention") + channelName msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention") + channelName
} else { } else {
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_non_mention") + channelName msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_non_mention") + channelName
@@ -625,7 +628,7 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
} }
} }
l4g.Debug("Sending push notification for user %v with msg of '%v'", user.Id, msg.Message) //l4g.Debug("Sending push notification for user %v with msg of '%v'", user.Id, msg.Message)
for _, session := range sessions { for _, session := range sessions {
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson())) tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))

Просмотреть файл

@@ -18,7 +18,9 @@ const (
PUSH_TYPE_MESSAGE = "message" PUSH_TYPE_MESSAGE = "message"
PUSH_TYPE_CLEAR = "clear" PUSH_TYPE_CLEAR = "clear"
CATEGORY_DM = "DIRECT_MESSAGE" // The category is set to handle a set of interactive Actions
// with the push notifications
CATEGORY_CAN_REPLY = "CAN_REPLY"
MHPNS = "https://push.mattermost.com" MHPNS = "https://push.mattermost.com"
) )
@@ -34,6 +36,8 @@ type PushNotification struct {
ContentAvailable int `json:"cont_ava"` ContentAvailable int `json:"cont_ava"`
TeamId string `json:"team_id"` TeamId string `json:"team_id"`
ChannelId string `json:"channel_id"` ChannelId string `json:"channel_id"`
PostId string `json:"post_id"`
RootId string `json:"root_id"`
ChannelName string `json:"channel_name"` ChannelName string `json:"channel_name"`
Type string `json:"type"` Type string `json:"type"`
SenderId string `json:"sender_id"` SenderId string `json:"sender_id"`