summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-06-30 16:06:59 +0800
committerGeorge Goldberg <george@gberg.me>2017-06-30 09:06:59 +0100
commiteea64f8049d90c5dcf14a739d640f5aa6a9c7add (patch)
treefabaa232bad7f4ebddf30b073c37a5962029f7fd /app
parentfb57b3dd53eaca28a557ea7e334e9d7216ce6aab (diff)
downloadchat-eea64f8049d90c5dcf14a739d640f5aa6a9c7add.tar.gz
chat-eea64f8049d90c5dcf14a739d640f5aa6a9c7add.tar.bz2
chat-eea64f8049d90c5dcf14a739d640f5aa6a9c7add.zip
[PLT-5864] Move teammate name display setting to the System Console (#6681)
* move teammate name display setting to the system console * update all the likes of TeammateNameDisplay names * fix gofmt error * rebase and fix conflict
Diffstat (limited to 'app')
-rw-r--r--app/diagnostics.go1
-rw-r--r--app/email_batching.go16
-rw-r--r--app/import_test.go10
-rw-r--r--app/team.go3
4 files changed, 5 insertions, 25 deletions
diff --git a/app/diagnostics.go b/app/diagnostics.go
index 65d67742e..dc0dbe597 100644
--- a/app/diagnostics.go
+++ b/app/diagnostics.go
@@ -209,6 +209,7 @@ func trackConfig() {
"max_notifications_per_channel": *utils.Cfg.TeamSettings.MaxNotificationsPerChannel,
"max_users_per_team": utils.Cfg.TeamSettings.MaxUsersPerTeam,
"max_channels_per_team": *utils.Cfg.TeamSettings.MaxChannelsPerTeam,
+ "teammate_name_display": *utils.Cfg.TeamSettings.TeammateNameDisplay,
"isdefault_site_name": isDefault(utils.Cfg.TeamSettings.SiteName, "Mattermost"),
"isdefault_custom_brand_text": isDefault(*utils.Cfg.TeamSettings.CustomBrandText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT),
"isdefault_custom_description_text": isDefault(*utils.Cfg.TeamSettings.CustomDescriptionText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT),
diff --git a/app/email_batching.go b/app/email_batching.go
index 6d7a376ef..5e4a36daf 100644
--- a/app/email_batching.go
+++ b/app/email_batching.go
@@ -4,7 +4,6 @@
package app
import (
- "database/sql"
"fmt"
"html/template"
"strconv"
@@ -163,7 +162,6 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
func sendBatchedEmailNotification(userId string, notifications []*batchedNotification) {
uchan := Srv.Store.User().Get(userId)
- pchan := Srv.Store.Preference().Get(userId, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_DISPLAY_NAME_FORMAT)
var user *model.User
if result := <-uchan; result.Err != nil {
@@ -174,17 +172,7 @@ func sendBatchedEmailNotification(userId string, notifications []*batchedNotific
}
translateFunc := utils.GetUserTranslations(user.Locale)
-
- var displayNameFormat string
- if result := <-pchan; result.Err != nil && result.Err.DetailedError != sql.ErrNoRows.Error() {
- l4g.Warn("api.email_batching.send_batched_email_notification.preferences.app_error")
- return
- } else if result.Err != nil {
- // no display name format saved, so fall back to default
- displayNameFormat = model.PREFERENCE_DEFAULT_DISPLAY_NAME_FORMAT
- } else {
- displayNameFormat = result.Data.(model.Preference).Value
- }
+ displayNameFormat := *utils.Cfg.TeamSettings.TeammateNameDisplay
var contents string
for _, notification := range notifications {
@@ -236,7 +224,7 @@ func renderBatchedPost(template *utils.HTMLTemplate, post *model.Post, teamName
l4g.Warn(utils.T("api.email_batching.render_batched_post.sender.app_error"))
return ""
} else {
- template.Props["SenderName"] = result.Data.(*model.User).GetDisplayNameForPreference(displayNameFormat)
+ template.Props["SenderName"] = result.Data.(*model.User).GetDisplayName(displayNameFormat)
}
if result := <-cchan; result.Err != nil {
diff --git a/app/import_test.go b/app/import_test.go
index 365383bad..0a45cca03 100644
--- a/app/import_test.go
+++ b/app/import_test.go
@@ -1586,7 +1586,6 @@ func TestImportImportUser(t *testing.T) {
Theme: ptrStr(`{"awayIndicator":"#DCBD4E","buttonBg":"#23A2FF","buttonColor":"#FFFFFF","centerChannelBg":"#ffffff","centerChannelColor":"#333333","codeTheme":"github","image":"/static/files/a4a388b38b32678e83823ef1b3e17766.png","linkColor":"#2389d7","mentionBj":"#2389d7","mentionColor":"#ffffff","mentionHighlightBg":"#fff2bb","mentionHighlightLink":"#2f81b7","newMessageSeparator":"#FF8800","onlineIndicator":"#7DBE00","sidebarBg":"#fafafa","sidebarHeaderBg":"#3481B9","sidebarHeaderTextColor":"#ffffff","sidebarText":"#333333","sidebarTextActiveBorder":"#378FD2","sidebarTextActiveColor":"#111111","sidebarTextHoverBg":"#e6f2fa","sidebarUnreadText":"#333333","type":"Mattermost"}`),
SelectedFont: ptrStr("Roboto Slab"),
UseMilitaryTime: ptrStr("true"),
- NameFormat: ptrStr("nickname_full_name"),
CollapsePreviews: ptrStr("true"),
MessageDisplay: ptrStr("compact"),
ChannelDisplayMode: ptrStr("centered"),
@@ -1625,10 +1624,6 @@ func TestImportImportUser(t *testing.T) {
t.Fatalf("Preference does not match.")
}
- if preference.Name == "name_format" && preference.Value != *data.NameFormat {
- t.Fatalf("Preference does not match.")
- }
-
if preference.Name == "collapse_previews" && preference.Value != *data.CollapsePreviews {
t.Fatalf("Preference does not match.")
}
@@ -1650,7 +1645,6 @@ func TestImportImportUser(t *testing.T) {
Theme: ptrStr(`{"awayIndicator":"#123456","buttonBg":"#23A2FF","buttonColor":"#FFFFFF","centerChannelBg":"#ffffff","centerChannelColor":"#333333","codeTheme":"github","image":"/static/files/a4a388b38b32678e83823ef1b3e17766.png","linkColor":"#2389d7","mentionBj":"#2389d7","mentionColor":"#ffffff","mentionHighlightBg":"#fff2bb","mentionHighlightLink":"#2f81b7","newMessageSeparator":"#FF8800","onlineIndicator":"#7DBE00","sidebarBg":"#fafafa","sidebarHeaderBg":"#3481B9","sidebarHeaderTextColor":"#ffffff","sidebarText":"#333333","sidebarTextActiveBorder":"#378FD2","sidebarTextActiveColor":"#111111","sidebarTextHoverBg":"#e6f2fa","sidebarUnreadText":"#333333","type":"Mattermost"}`),
SelectedFont: ptrStr("Lato"),
UseMilitaryTime: ptrStr("false"),
- NameFormat: ptrStr("full_name"),
CollapsePreviews: ptrStr("false"),
MessageDisplay: ptrStr("clean"),
ChannelDisplayMode: ptrStr("full"),
@@ -1684,10 +1678,6 @@ func TestImportImportUser(t *testing.T) {
t.Fatalf("Preference does not match.")
}
- if preference.Name == "name_format" && preference.Value != *data.NameFormat {
- t.Fatalf("Preference does not match.")
- }
-
if preference.Name == "collapse_previews" && preference.Value != *data.CollapsePreviews {
t.Fatalf("Preference does not match.")
}
diff --git a/app/team.go b/app/team.go
index be15b8a39..8f2f7cfcb 100644
--- a/app/team.go
+++ b/app/team.go
@@ -657,7 +657,8 @@ func InviteNewUsersToTeam(emailList []string, teamId, senderId string) *model.Ap
user = result.Data.(*model.User)
}
- SendInviteEmails(team, user.GetDisplayName(), emailList, utils.GetSiteURL())
+ nameFormat := *utils.Cfg.TeamSettings.TeammateNameDisplay
+ SendInviteEmails(team, user.GetDisplayName(nameFormat), emailList, utils.GetSiteURL())
return nil
}