summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-24 18:10:49 -0300
committerGitHub <noreply@github.com>2016-08-24 18:10:49 -0300
commite6d15f77e8fa4ec27e104297667b28dc5f8517ca (patch)
treeced33e8d5a3571aac144375daea1d4b16b843c37 /model
parentdeb1361a0d67421fbeacc466b57c05d10da4c631 (diff)
downloadchat-e6d15f77e8fa4ec27e104297667b28dc5f8517ca.tar.gz
chat-e6d15f77e8fa4ec27e104297667b28dc5f8517ca.tar.bz2
chat-e6d15f77e8fa4ec27e104297667b28dc5f8517ca.zip
PLT-3942 Add real-time updates for center channel profile picture popover (#3871)
* PLT-3942 Add real-time updates for center channel profile picture pop-over * Send user data with the websocket event to prevent further requests * Add helper for profile sanitation
Diffstat (limited to 'model')
-rw-r--r--model/user.go16
-rw-r--r--model/websocket_message.go1
2 files changed, 17 insertions, 0 deletions
diff --git a/model/user.go b/model/user.go
index 3da862b6b..f857d5ef4 100644
--- a/model/user.go
+++ b/model/user.go
@@ -251,6 +251,22 @@ func (u *User) ClearNonProfileFields() {
u.FailedAttempts = 0
}
+func (u *User) SanitizeProfile(isSystemAdmin, pwdupdate, fullname, email bool) {
+ options := map[string]bool{}
+ options["passwordupdate"] = pwdupdate
+
+ if isSystemAdmin {
+ options["fullname"] = true
+ options["email"] = true
+ } else {
+ options["fullname"] = fullname
+ options["email"] = email
+ u.ClearNonProfileFields()
+ }
+
+ u.Sanitize(options)
+}
+
func (u *User) MakeNonNil() {
if u.Props == nil {
u.Props = make(map[string]string)
diff --git a/model/websocket_message.go b/model/websocket_message.go
index ae9a140c3..0ad455997 100644
--- a/model/websocket_message.go
+++ b/model/websocket_message.go
@@ -19,6 +19,7 @@ const (
WEBSOCKET_EVENT_NEW_USER = "new_user"
WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
WEBSOCKET_EVENT_USER_ADDED = "user_added"
+ WEBSOCKET_EVENT_USER_UPDATED = "user_updated"
WEBSOCKET_EVENT_USER_REMOVED = "user_removed"
WEBSOCKET_EVENT_PREFERENCE_CHANGED = "preference_changed"
WEBSOCKET_EVENT_EPHEMERAL_MESSAGE = "ephemeral_message"