diff options
author | enahum <nahumhbl@gmail.com> | 2016-11-21 12:18:05 -0300 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-11-21 07:18:05 -0800 |
commit | 5cf040541121bd8a87f7be4811bbb3d0ea671308 (patch) | |
tree | 4f13047a61983a9c3a38d7502b9061468ae85872 /api | |
parent | 6e8647aaf198eda1999737d5537a84449ef31687 (diff) | |
download | chat-5cf040541121bd8a87f7be4811bbb3d0ea671308.tar.gz chat-5cf040541121bd8a87f7be4811bbb3d0ea671308.tar.bz2 chat-5cf040541121bd8a87f7be4811bbb3d0ea671308.zip |
Fix DM panic when user hasn't joined any team (#4604)
Diffstat (limited to 'api')
-rw-r--r-- | api/post.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/api/post.go b/api/post.go index bcbdd7760..69be29134 100644 --- a/api/post.go +++ b/api/post.go @@ -646,7 +646,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel * } if userAllowsEmails && status.Status != model.STATUS_ONLINE { - sendNotificationEmail(c, post, profileMap[id], channel, team, senderName, sender) + go sendNotificationEmail(c, post, profileMap[id], channel, team, senderName, sender) } } } @@ -702,7 +702,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel * } if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) { - sendPushNotification(post, profileMap[id], channel, senderName, true) + go sendPushNotification(post, profileMap[id], channel, senderName, true) } } @@ -715,7 +715,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel * } if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) { - sendPushNotification(post, profileMap[id], channel, senderName, false) + go sendPushNotification(post, profileMap[id], channel, senderName, false) } } } @@ -777,8 +777,11 @@ func sendNotificationEmail(c *Context, post *model.Post, user *model.User, chann } } - if !found { + if !found && len(teams) > 0 { team = teams[0] + } else { + // in case the user hasn't joined any teams we send them to the select_team page + team = &model.Team{Name: "select_team", DisplayName: utils.Cfg.TeamSettings.SiteName} } } } @@ -849,7 +852,12 @@ func sendNotificationEmail(c *Context, post *model.Post, user *model.User, chann bodyPage := utils.NewHTMLTemplate("post_body", user.Locale) bodyPage.Props["SiteURL"] = c.GetSiteURL() bodyPage.Props["PostMessage"] = getMessageForNotification(post, userLocale) - bodyPage.Props["TeamLink"] = teamURL + "/pl/" + post.Id + if team.Name != "select_team" { + bodyPage.Props["TeamLink"] = teamURL + "/pl/" + post.Id + } else { + bodyPage.Props["TeamLink"] = teamURL + } + bodyPage.Props["BodyText"] = bodyText bodyPage.Props["Button"] = userLocale("api.templates.post_body.button") bodyPage.Html["Info"] = template.HTML(userLocale("api.templates.post_body.info", |