summaryrefslogtreecommitdiffstats
path: root/api/team.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-29 18:35:33 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-29 18:35:33 -0400
commit1055d8f4a116cdbdb3cf38ecf4781c7fa761d7bd (patch)
tree35264d85bc5905d072eb95334c0b28493342cc06 /api/team.go
parent3dee6ebb03981099540386ec1f8df3d0a98d9520 (diff)
downloadchat-1055d8f4a116cdbdb3cf38ecf4781c7fa761d7bd.tar.gz
chat-1055d8f4a116cdbdb3cf38ecf4781c7fa761d7bd.tar.bz2
chat-1055d8f4a116cdbdb3cf38ecf4781c7fa761d7bd.zip
Fixed team API to properly provide team names for the Find My Team email
Diffstat (limited to 'api/team.go')
-rw-r--r--api/team.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/api/team.go b/api/team.go
index c9fe42ecc..01c8e50b6 100644
--- a/api/team.go
+++ b/api/team.go
@@ -275,11 +275,24 @@ func emailTeams(c *Context, w http.ResponseWriter, r *http.Request) {
subjectPage := NewServerTemplatePage("find_teams_subject", c.GetSiteURL())
bodyPage := NewServerTemplatePage("find_teams_body", c.GetSiteURL())
- if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil {
- l4g.Error("An error occured while sending an email in emailTeams err=%v", err)
- }
+ if result := <-Srv.Store.Team().GetTeamsForEmail(email); result.Err != nil {
+ c.Err = result.Err
+ } else {
+ teams := result.Data.([]*model.Team)
- w.Write([]byte(model.MapToJson(m)))
+ // the template expects Props to be a map with team names as the keys
+ props := make(map[string]string)
+ for _, team := range teams {
+ props[team.Name] = team.Name
+ }
+ bodyPage.Props = props
+
+ if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil {
+ l4g.Error("An error occured while sending an email in emailTeams err=%v", err)
+ }
+
+ w.Write([]byte(model.MapToJson(m)))
+ }
}
func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) {