From 2547e47eabe9de1dd7aeda139692df1417240f35 Mon Sep 17 00:00:00 2001 From: Allan Guwatudde Date: Wed, 18 Aug 2021 16:14:47 +0300 Subject: [PATCH] [MM-37727] - Self-managed: Update email template to new branding - Mention (#18134) * [MM-37727] - Self-managed: Update email template to new branding - Mention * fix lint * truncate long channel names * change rgba to rgb * feedback impl * adjust character truncation length Co-authored-by: Mattermod --- app/notification_email.go | 14 +++++++- templates/messages_notification.html | 52 +++++++++++++++++++--------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/app/notification_email.go b/app/notification_email.go index 52fbf5ee58..ed2c729e79 100644 --- a/app/notification_email.go +++ b/app/notification_email.go @@ -172,6 +172,18 @@ func getGroupMessageNotificationEmailSubject(user *model.User, post *model.Post, return translateFunc("app.notification.subject.group_message.generic", subjectParameters) } +/** +* If the name is longer than i characters, replace remaining characters with ... + */ +func truncateUserNames(name string, i int) string { + runes := []rune(name) + if len(runes) > i { + newString := string(runes[:i]) + return newString + "..." + } + return name +} + type postData struct { SenderName string ChannelName string @@ -187,7 +199,7 @@ type postData struct { */ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post, channel *model.Channel, channelName string, senderName string, teamName string, landingURL string, emailNotificationContentsType string, useMilitaryTime bool, translateFunc i18n.TranslateFunc, senderPhoto string) (string, error) { pData := postData{ - SenderName: senderName, + SenderName: truncateUserNames(senderName, 22), SenderPhoto: senderPhoto, } diff --git a/templates/messages_notification.html b/templates/messages_notification.html index 1e83de048b..c71e1553a5 100644 --- a/templates/messages_notification.html +++ b/templates/messages_notification.html @@ -82,6 +82,22 @@ } } +