Skip to content

Commit

Permalink
[mattermostGH-15906][MM-22844] Redesign reset password and invite ema…
Browse files Browse the repository at this point in the history
…ils (mattermost#17029)

Automatic Merge
  • Loading branch information
jp0707 committed Mar 10, 2021
1 parent f5590d4 commit 41ab05c
Show file tree
Hide file tree
Showing 10 changed files with 1,292 additions and 129 deletions.
36 changes: 18 additions & 18 deletions app/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ func (es *EmailService) SendPasswordResetEmail(email string, token *model.Token,
bodyPage := es.newEmailTemplate("reset_body", locale)
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = T("api.templates.reset_body.title")
bodyPage.Props["Info1"] = i18n.TranslateAsHTML(T, "api.templates.reset_body.info1", nil)
bodyPage.Props["Info2"] = T("api.templates.reset_body.info2")
bodyPage.Props["ResetUrl"] = link
bodyPage.Props["SubTitle"] = T("api.templates.reset_body.subTitle")
bodyPage.Props["Info"] = T("api.templates.reset_body.info")
bodyPage.Props["ButtonURL"] = link
bodyPage.Props["Button"] = T("api.templates.reset_body.button")
bodyPage.Props["QuestionTitle"] = T("api.templates.questions_footer.title")
bodyPage.Props["QuestionInfo"] = T("api.templates.questions_footer.info")

if err := es.sendMail(email, subject, bodyPage.Render()); err != nil {
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.send.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
Expand Down Expand Up @@ -371,13 +373,13 @@ func (es *EmailService) SendInviteEmails(team *model.Team, senderName string, se

bodyPage := es.newEmailTemplate("invite_body", "")
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = i18n.T("api.templates.invite_body.title")
bodyPage.HTML["Info"] = i18n.TranslateAsHTML(i18n.T, "api.templates.invite_body.info",
map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["Title"] = i18n.T("api.templates.invite_body.title", map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["SubTitle"] = i18n.T("api.templates.invite_body.subTitle")
bodyPage.Props["Button"] = i18n.T("api.templates.invite_body.button")
bodyPage.HTML["ExtraInfo"] = i18n.TranslateAsHTML(i18n.T, "api.templates.invite_body.extra_info",
map[string]interface{}{"TeamDisplayName": team.DisplayName})
bodyPage.Props["TeamURL"] = siteURL + "/" + team.Name
bodyPage.Props["SenderName"] = senderName
bodyPage.Props["InviteFooterTitle"] = i18n.T("api.templates.invite_body_footer.title")
bodyPage.Props["InviteFooterInfo"] = i18n.T("api.templates.invite_body_footer.info")
bodyPage.Props["InviteFooterLearnMore"] = i18n.T("api.templates.invite_body_footer.learn_more")

token := model.NewToken(
TokenTypeTeamInvitation,
Expand All @@ -394,7 +396,7 @@ func (es *EmailService) SendInviteEmails(team *model.Team, senderName string, se
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
continue
}
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))
bodyPage.Props["ButtonURL"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))

if err := es.sendMail(invite, subject, bodyPage.Render()); err != nil {
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
Expand Down Expand Up @@ -430,19 +432,17 @@ func (es *EmailService) sendGuestInviteEmails(team *model.Team, channels []*mode

bodyPage := es.newEmailTemplate("invite_body", "")
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = i18n.T("api.templates.invite_body.title")
bodyPage.HTML["Info"] = i18n.TranslateAsHTML(i18n.T, "api.templates.invite_body_guest.info",
map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["Title"] = i18n.T("api.templates.invite_body.title", map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["SubTitle"] = i18n.T("api.templates.invite_body_guest.subTitle")
bodyPage.Props["Button"] = i18n.T("api.templates.invite_body.button")
bodyPage.Props["SenderName"] = senderName
bodyPage.Props["SenderId"] = senderUserId
bodyPage.Props["Message"] = ""
if message != "" {
bodyPage.Props["Message"] = message
}
bodyPage.HTML["ExtraInfo"] = i18n.TranslateAsHTML(i18n.T, "api.templates.invite_body.extra_info",
map[string]interface{}{"TeamDisplayName": team.DisplayName})
bodyPage.Props["TeamURL"] = siteURL + "/" + team.Name
bodyPage.Props["InviteFooterTitle"] = i18n.T("api.templates.invite_body_footer.title")
bodyPage.Props["InviteFooterInfo"] = i18n.T("api.templates.invite_body_footer.info")
bodyPage.Props["InviteFooterLearnMore"] = i18n.T("api.templates.invite_body_footer.learn_more")

channelIDs := []string{}
for _, channel := range channels {
Expand All @@ -469,7 +469,7 @@ func (es *EmailService) sendGuestInviteEmails(team *model.Team, channels []*mode
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
continue
}
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))
bodyPage.Props["ButtonURL"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))

if !*es.srv.Config().EmailSettings.SendEmailNotifications {
mlog.Info("sending invitation ", mlog.String("to", invite), mlog.String("link", bodyPage.Props["Link"].(string)))
Expand Down
36 changes: 22 additions & 14 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2760,23 +2760,31 @@
},
{
"id": "api.templates.invite_body.button",
"translation": "Join Team"
"translation": "Join now"
},
{
"id": "api.templates.invite_body.extra_info",
"translation": "Mattermost lets you share messages and files from your PC or phone, with instant search and archiving. After you’ve joined [[{{.TeamDisplayName}}]], you can sign-in to your new team and access these features anytime from the web address:"
"id": "api.templates.invite_body.subTitle",
"translation": "Start collaborating with your team on Mattermost"
},
{
"id": "api.templates.invite_body.info",
"translation": "[[{{.SenderName}}]], has invited you to join [[{{.TeamDisplayName}}]]."
"id": "api.templates.invite_body.title",
"translation": "{{ .SenderName }} invited you to join the {{ .TeamDisplayName }} team."
},
{
"id": "api.templates.invite_body.title",
"translation": "You've been invited"
"id": "api.templates.invite_body_footer.info",
"translation": "Mattermost is a flexible, open source messaging platform that enables secure team collaboration."
},
{
"id": "api.templates.invite_body_footer.learn_more",
"translation": "Learn more"
},
{
"id": "api.templates.invite_body_footer.title",
"translation": "What is Mattermost?"
},
{
"id": "api.templates.invite_body_guest.info",
"translation": "[[{{.SenderName}}]], has invited you to join team [[{{.TeamDisplayName}}]] as a guest."
"id": "api.templates.invite_body_guest.subTitle",
"translation": "You were invited as a guest to collaborate with the team"
},
{
"id": "api.templates.invite_guest_subject",
Expand Down Expand Up @@ -3003,16 +3011,16 @@
"translation": "Reset Password"
},
{
"id": "api.templates.reset_body.info1",
"translation": "To change your password, click \"Reset Password\" below."
"id": "api.templates.reset_body.info",
"translation": "The password reset link expires in 24 hours."
},
{
"id": "api.templates.reset_body.info2",
"translation": "If you did not mean to reset your password, please ignore this email and your password will remain the same. The password reset link expires in 24 hours."
"id": "api.templates.reset_body.subTitle",
"translation": "Click the button below to reset your password. If you didn’t request this, you can safely ignore this email."
},
{
"id": "api.templates.reset_body.title",
"translation": "You requested a password reset"
"translation": "Reset Your Password"
},
{
"id": "api.templates.reset_subject",
Expand Down

0 comments on commit 41ab05c

Please sign in to comment.