diff options
author | Joram Wilander <jwawilander@gmail.com> | 2018-06-21 13:42:20 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-06-21 10:42:20 -0700 |
commit | 46f969e5ddbe4404dbc82dbe78ab2fa101d9922e (patch) | |
tree | f526b349e193f085b2641548ebf97f3c448ac5a6 /model/status.go | |
parent | d36ad6cb54b636fd315794be6aa9fd76c995e264 (diff) | |
download | chat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.tar.gz chat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.tar.bz2 chat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.zip |
MM-10425 Include active_channel in cluster update user status messages (#8967)
* Include active_channel in cluster update user status messages
* Update to use new ToJson method
* Update tests
Diffstat (limited to 'model/status.go')
-rw-r--r-- | model/status.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/model/status.go b/model/status.go index cf5899446..7888c60a4 100644 --- a/model/status.go +++ b/model/status.go @@ -24,10 +24,18 @@ type Status struct { Status string `json:"status"` Manual bool `json:"manual"` LastActivityAt int64 `json:"last_activity_at"` - ActiveChannel string `json:"-" db:"-"` + ActiveChannel string `json:"active_channel,omitempty" db:"-"` } func (o *Status) ToJson() string { + tempChannelId := o.ActiveChannel + o.ActiveChannel = "" + b, _ := json.Marshal(o) + o.ActiveChannel = tempChannelId + return string(b) +} + +func (o *Status) ToClusterJson() string { b, _ := json.Marshal(o) return string(b) } @@ -39,7 +47,18 @@ func StatusFromJson(data io.Reader) *Status { } func StatusListToJson(u []*Status) string { + activeChannels := make([]string, len(u)) + for index, s := range u { + activeChannels[index] = s.ActiveChannel + s.ActiveChannel = "" + } + b, _ := json.Marshal(u) + + for index, s := range u { + s.ActiveChannel = activeChannels[index] + } + return string(b) } |