From bc48281f7aedabf5cb830a02b5e081b6554115cf Mon Sep 17 00:00:00 2001 From: nickago Date: Tue, 28 Jul 2015 13:28:18 -0700 Subject: Changed all templates to use site url instead of team url for finding the 'static' directory --- api/api.go | 4 ++-- api/context.go | 2 +- api/post.go | 4 ++-- api/team.go | 6 ++---- api/templates/email_change_body.html | 6 +++--- api/templates/find_teams_body.html | 4 ++-- api/templates/invite_body.html | 4 ++-- api/templates/password_change_body.html | 6 +++--- api/templates/post_body.html | 4 ++-- api/templates/reset_body.html | 4 ++-- api/templates/signup_team_body.html | 4 ++-- api/templates/verify_body.html | 4 ++-- api/templates/welcome_body.html | 6 +++--- api/user.go | 35 ++++++++++++++++++--------------- 14 files changed, 47 insertions(+), 46 deletions(-) diff --git a/api/api.go b/api/api.go index 25f3376c6..2ea27ed9f 100644 --- a/api/api.go +++ b/api/api.go @@ -16,10 +16,10 @@ var ServerTemplates *template.Template type ServerTemplatePage Page -func NewServerTemplatePage(templateName, teamURL string) *ServerTemplatePage { +func NewServerTemplatePage(templateName, siteURL string) *ServerTemplatePage { props := make(map[string]string) props["AnalyticsUrl"] = utils.Cfg.ServiceSettings.AnalyticsUrl - return &ServerTemplatePage{TemplateName: templateName, SiteName: utils.Cfg.ServiceSettings.SiteName, FeedbackEmail: utils.Cfg.EmailSettings.FeedbackEmail, TeamURL: teamURL, Props: props} + return &ServerTemplatePage{TemplateName: templateName, SiteName: utils.Cfg.ServiceSettings.SiteName, FeedbackEmail: utils.Cfg.EmailSettings.FeedbackEmail, SiteURL: siteURL, Props: props} } func (me *ServerTemplatePage) Render() string { diff --git a/api/context.go b/api/context.go index 16da0a6eb..e3f279e90 100644 --- a/api/context.go +++ b/api/context.go @@ -32,7 +32,7 @@ type Page struct { Title string SiteName string FeedbackEmail string - TeamURL string + SiteURL string Props map[string]string } diff --git a/api/post.go b/api/post.go index f96320639..f6699d181 100644 --- a/api/post.go +++ b/api/post.go @@ -377,7 +377,7 @@ func fireAndForgetNotifications(post *model.Post, teamId, siteURL string) { location, _ := time.LoadLocation("UTC") tm := time.Unix(post.CreateAt/1000, 0).In(location) - subjectPage := NewServerTemplatePage("post_subject", teamURL) + subjectPage := NewServerTemplatePage("post_subject", siteURL) subjectPage.Props["TeamDisplayName"] = teamDisplayName subjectPage.Props["SubjectText"] = subjectText subjectPage.Props["Month"] = tm.Month().String()[:3] @@ -395,7 +395,7 @@ func fireAndForgetNotifications(post *model.Post, teamId, siteURL string) { continue } - bodyPage := NewServerTemplatePage("post_body", teamURL) + bodyPage := NewServerTemplatePage("post_body", siteURL) bodyPage.Props["Nickname"] = profileMap[id].FirstName bodyPage.Props["TeamDisplayName"] = teamDisplayName bodyPage.Props["ChannelName"] = channelName diff --git a/api/team.go b/api/team.go index 01c8e50b6..e6b8f4e14 100644 --- a/api/team.go +++ b/api/team.go @@ -344,8 +344,6 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) { func InviteMembers(c *Context, team *model.Team, user *model.User, invites []string) { for _, invite := range invites { if len(invite) > 0 { - teamURL := "" - teamURL = c.GetTeamURLFromTeam(team) sender := user.GetDisplayName() @@ -356,10 +354,10 @@ func InviteMembers(c *Context, team *model.Team, user *model.User, invites []str senderRole = "member" } - subjectPage := NewServerTemplatePage("invite_subject", teamURL) + subjectPage := NewServerTemplatePage("invite_subject", c.GetSiteURL()) subjectPage.Props["SenderName"] = sender subjectPage.Props["TeamDisplayName"] = team.DisplayName - bodyPage := NewServerTemplatePage("invite_body", teamURL) + bodyPage := NewServerTemplatePage("invite_body", c.GetSiteURL()) bodyPage.Props["TeamDisplayName"] = team.DisplayName bodyPage.Props["SenderName"] = sender bodyPage.Props["SenderStatus"] = senderRole diff --git a/api/templates/email_change_body.html b/api/templates/email_change_body.html index 439fffd5b..c4e1cf39d 100644 --- a/api/templates/email_change_body.html +++ b/api/templates/email_change_body.html @@ -9,7 +9,7 @@ @@ -18,7 +18,7 @@ @@ -34,7 +34,7 @@
- +

You updated your email

-

You updated your email for {{.Props.TeamDisplayName}} on {{ .TeamURL }}
If this change wasn't initiated by you, please reply to this email and let us know.

+

You updated your email for {{.Props.TeamDisplayName}} on {{ .Props.TeamURL }}
If this change wasn't initiated by you, please reply to this email and let us know.

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/find_teams_body.html b/api/templates/find_teams_body.html index a73ed0ad4..bd151a819 100644 --- a/api/templates/find_teams_body.html +++ b/api/templates/find_teams_body.html @@ -9,7 +9,7 @@ @@ -42,7 +42,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/invite_body.html b/api/templates/invite_body.html index ad0658e3d..568a0d893 100644 --- a/api/templates/invite_body.html +++ b/api/templates/invite_body.html @@ -9,7 +9,7 @@ @@ -37,7 +37,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/password_change_body.html b/api/templates/password_change_body.html index 1d4a6e1c8..6fc9f2822 100644 --- a/api/templates/password_change_body.html +++ b/api/templates/password_change_body.html @@ -9,7 +9,7 @@ @@ -18,7 +18,7 @@ @@ -34,7 +34,7 @@
- +

You updated your password

-

You updated your password for {{.Props.TeamDisplayName}} on {{ .TeamURL }} by {{.Props.Method}}.
If this change wasn't initiated by you, please reply to this email and let us know.

+

You updated your password for {{.Props.TeamDisplayName}} on {{ .Props.TeamURL }} by {{.Props.Method}}.
If this change wasn't initiated by you, please reply to this email and let us know.

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/post_body.html b/api/templates/post_body.html index 0aa913db5..a1df5b4c9 100644 --- a/api/templates/post_body.html +++ b/api/templates/post_body.html @@ -9,7 +9,7 @@ @@ -37,7 +37,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/reset_body.html b/api/templates/reset_body.html index 4c2fec1e7..a6e6269c0 100644 --- a/api/templates/reset_body.html +++ b/api/templates/reset_body.html @@ -9,7 +9,7 @@ @@ -37,7 +37,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/signup_team_body.html b/api/templates/signup_team_body.html index 5e60a042b..71df0b9c8 100644 --- a/api/templates/signup_team_body.html +++ b/api/templates/signup_team_body.html @@ -9,7 +9,7 @@ @@ -40,7 +40,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/verify_body.html b/api/templates/verify_body.html index 1a68c16f5..6ba11d845 100644 --- a/api/templates/verify_body.html +++ b/api/templates/verify_body.html @@ -9,7 +9,7 @@ @@ -37,7 +37,7 @@
- +

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/templates/welcome_body.html b/api/templates/welcome_body.html index cc4d95fb1..f16f50e14 100644 --- a/api/templates/welcome_body.html +++ b/api/templates/welcome_body.html @@ -9,7 +9,7 @@ @@ -18,7 +18,7 @@ @@ -34,7 +34,7 @@
- +

You joined the {{.Props.TeamDisplayName}} team at {{.SiteName}}!

-

Please let me know if you have any questions.
Enjoy your stay at {{.SiteName}}.

+

Please let me know if you have any questions.
Enjoy your stay at {{.SiteName}}.

- +

(c) 2015 SpinPunch, Inc. 855 El Camino Real, 13A-168, Palo Alto, CA, 94301.
diff --git a/api/user.go b/api/user.go index e2d80b366..ad5385695 100644 --- a/api/user.go +++ b/api/user.go @@ -209,14 +209,15 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User { } } -func fireAndForgetWelcomeEmail(name, email, teamDisplayName, link string) { +func fireAndForgetWelcomeEmail(name, email, teamDisplayName, link, siteURL string) { go func() { - subjectPage := NewServerTemplatePage("welcome_subject", link) - bodyPage := NewServerTemplatePage("welcome_body", link) + subjectPage := NewServerTemplatePage("welcome_subject", siteURL) + bodyPage := NewServerTemplatePage("welcome_body", siteURL) bodyPage.Props["Nickname"] = name bodyPage.Props["TeamDisplayName"] = teamDisplayName bodyPage.Props["FeedbackName"] = utils.Cfg.EmailSettings.FeedbackName + bodyPage.Props["TeamURL"] = link if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil { l4g.Error("Failed to send welcome email successfully err=%v", err) @@ -230,9 +231,9 @@ func FireAndForgetVerifyEmail(userId, userEmail, teamName, teamDisplayName, site link := fmt.Sprintf("%s/verify_email?uid=%s&hid=%s&teamname=%s&email=%s", siteURL, userId, model.HashPassword(userId), teamName, userEmail) - subjectPage := NewServerTemplatePage("verify_subject", teamURL) + subjectPage := NewServerTemplatePage("verify_subject", siteURL) subjectPage.Props["TeamDisplayName"] = teamDisplayName - bodyPage := NewServerTemplatePage("verify_body", teamURL) + bodyPage := NewServerTemplatePage("verify_body", siteURL) bodyPage.Props["TeamDisplayName"] = teamDisplayName bodyPage.Props["VerifyUrl"] = link @@ -800,7 +801,7 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) { l4g.Error(tresult.Err.Message) } else { team := tresult.Data.(*model.Team) - fireAndForgetEmailChangeEmail(rusers[1].Email, team.DisplayName, c.GetTeamURLFromTeam(team)) + fireAndForgetEmailChangeEmail(rusers[1].Email, team.DisplayName, c.GetTeamURLFromTeam(team), c.GetSiteURL()) } } @@ -879,7 +880,7 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) { l4g.Error(tresult.Err.Message) } else { team := tresult.Data.(*model.Team) - fireAndForgetPasswordChangeEmail(user.Email, team.DisplayName, c.GetTeamURLFromTeam(team), "using the settings menu") + fireAndForgetPasswordChangeEmail(user.Email, team.DisplayName, c.GetTeamURLFromTeam(team), c.GetSiteURL(), "using the settings menu") } data := make(map[string]string) @@ -1069,8 +1070,8 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) { link := fmt.Sprintf("%s/reset_password?d=%s&h=%s", c.GetTeamURLFromTeam(team), url.QueryEscape(data), url.QueryEscape(hash)) - subjectPage := NewServerTemplatePage("reset_subject", c.GetTeamURLFromTeam(team)) - bodyPage := NewServerTemplatePage("reset_body", c.GetTeamURLFromTeam(team)) + subjectPage := NewServerTemplatePage("reset_subject", c.GetSiteURL()) + bodyPage := NewServerTemplatePage("reset_body", c.GetSiteURL()) bodyPage.Props["ResetUrl"] = link if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil { @@ -1160,19 +1161,20 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAuditWithUserId(userId, "success") } - fireAndForgetPasswordChangeEmail(user.Email, team.DisplayName, c.GetTeamURLFromTeam(team), "using a reset password link") + fireAndForgetPasswordChangeEmail(user.Email, team.DisplayName, c.GetTeamURLFromTeam(team), c.GetSiteURL(), "using a reset password link") props["new_password"] = "" w.Write([]byte(model.MapToJson(props))) } -func fireAndForgetPasswordChangeEmail(email, teamDisplayName, teamURL, method string) { +func fireAndForgetPasswordChangeEmail(email, teamDisplayName, teamURL, siteURL, method string) { go func() { - subjectPage := NewServerTemplatePage("password_change_subject", teamURL) + subjectPage := NewServerTemplatePage("password_change_subject", siteURL) subjectPage.Props["TeamDisplayName"] = teamDisplayName - bodyPage := NewServerTemplatePage("password_change_body", teamURL) + bodyPage := NewServerTemplatePage("password_change_body", siteURL) bodyPage.Props["TeamDisplayName"] = teamDisplayName + bodyPage.Props["TeamURL"] = teamURL bodyPage.Props["Method"] = method if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil { @@ -1182,13 +1184,14 @@ func fireAndForgetPasswordChangeEmail(email, teamDisplayName, teamURL, method st }() } -func fireAndForgetEmailChangeEmail(email, teamDisplayName, teamURL string) { +func fireAndForgetEmailChangeEmail(email, teamDisplayName, teamURL, siteURL string) { go func() { - subjectPage := NewServerTemplatePage("email_change_subject", teamURL) + subjectPage := NewServerTemplatePage("email_change_subject", siteURL) subjectPage.Props["TeamDisplayName"] = teamDisplayName - bodyPage := NewServerTemplatePage("email_change_body", teamURL) + bodyPage := NewServerTemplatePage("email_change_body", siteURL) bodyPage.Props["TeamDisplayName"] = teamDisplayName + bodyPage.Props["TeamURL"] = teamURL if err := utils.SendMail(email, subjectPage.Render(), bodyPage.Render()); err != nil { l4g.Error("Failed to send update password email successfully err=%v", err) -- cgit v1.2.3-1-g7c22