summaryrefslogtreecommitdiffstats
path: root/model/user.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-04-20 08:44:18 -0400
committerGitHub <noreply@github.com>2018-04-20 08:44:18 -0400
commit283f34b9c6d207f0a103e7b4c7f6da2c7481c3ef (patch)
tree9a9d0dfb9f536d37e9817e3407c32e7ec0c11cdf /model/user.go
parent7987c95fcd7f7a9e6d4d174be403bf170f7b9115 (diff)
downloadchat-283f34b9c6d207f0a103e7b4c7f6da2c7481c3ef.tar.gz
chat-283f34b9c6d207f0a103e7b4c7f6da2c7481c3ef.tar.bz2
chat-283f34b9c6d207f0a103e7b4c7f6da2c7481c3ef.zip
MM-10007 Send an admin and regular WS events when a user is updated (#8588)
* Add user.DeepCopy() function * Add omit admins/non-admins to WS broadcast and use for updating users * Updates per feedback and adding unit test for ShouldSendEvent
Diffstat (limited to 'model/user.go')
-rw-r--r--model/user.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/model/user.go b/model/user.go
index efe8f8db9..6fbdb09e8 100644
--- a/model/user.go
+++ b/model/user.go
@@ -96,6 +96,23 @@ type UserAuth struct {
AuthService string `json:"auth_service,omitempty"`
}
+func (u *User) DeepCopy() *User {
+ copyUser := *u
+ if u.AuthData != nil {
+ copyUser.AuthData = NewString(*u.AuthData)
+ }
+ if u.Props != nil {
+ copyUser.Props = CopyStringMap(u.Props)
+ }
+ if u.NotifyProps != nil {
+ copyUser.NotifyProps = CopyStringMap(u.NotifyProps)
+ }
+ if u.Timezone != nil {
+ copyUser.Timezone = CopyStringMap(u.Timezone)
+ }
+ return &copyUser
+}
+
// IsValid validates the user and returns an error if it isn't configured
// correctly.
func (u *User) IsValid() *AppError {