MM-38093: updates notifications copy on CRT replies (#18332)

MM-38093: updates notifications copy on CRT replies

Updates texts form push and email notifications when the user has CRT "on"
and the post is a reply to a thread.

Email batches text aware of CRT threads

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Kyriakos Z
2021-09-10 11:12:18 +03:00
коммит произвёл GitHub
родитель 6a0ba98fab
Коммит 1c8bc159e0
6 изменённых файлов: 89 добавлений и 14 удалений

Просмотреть файл

@@ -225,6 +225,16 @@ func (es *Service) sendBatchedEmailNotification(userID string, notifications []*
emailNotificationContentsType = *es.config().EmailSettings.EmailNotificationContentsType
}
// check if user has CRT set to ON
threadsEnabled := false
if *es.config().ServiceSettings.CollapsedThreads != model.CollapsedThreadsDisabled {
threadsEnabled = *es.config().ServiceSettings.CollapsedThreads == model.CollapsedThreadsDefaultOn
// check if a participant has overridden collapsed threads settings
if preference, errCrt := es.store.Preference().Get(userID, model.PreferenceCategoryDisplaySettings, model.PreferenceNameCollapsedThreadsEnabled); errCrt == nil {
threadsEnabled = preference.Value == "on"
}
}
if emailNotificationContentsType == model.EmailNotificationContentsFull {
for i, notification := range notifications {
sender, errSender := es.userService.GetUser(notification.post.UserId)
@@ -261,11 +271,20 @@ func (es *Service) sendBatchedEmailNotification(userID string, notifications []*
MessageURL := siteURL + "/" + notification.teamName + "/pl/" + notification.post.Id
channelName := channel.DisplayName
if threadsEnabled && notification.post.RootId != "" {
props := map[string]interface{}{"channelName": channelName}
channelName = translateFunc("api.push_notification.title.collapsed_threads", props)
if channel.Type == model.ChannelTypeDirect {
channelName = translateFunc("api.push_notification.title.collapsed_threads_dm")
}
}
postsData = append(postsData, &postData{
SenderPhoto: senderPhoto,
SenderName: sender.GetDisplayName(displayNameFormat),
Time: t,
ChannelName: channel.DisplayName,
ChannelName: channelName,
Message: template.HTML(es.GetMessageForNotification(notification.post, translateFunc)),
MessageURL: MessageURL,
})