diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-06-26 16:46:58 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-06-26 16:46:57 -0400 |
commit | 2d7cd02abcd62ffd60fe3c6e16e5189169de349e (patch) | |
tree | 93fde76e72e39577ffb70a6ff0922e5a81ffc973 /model/channel.go | |
parent | 164e030d33b03cab347ddcdf064615cb9e144317 (diff) | |
download | chat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.tar.gz chat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.tar.bz2 chat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.zip |
MM-10833: send down computed channel props (#8953)
* MM-10833: send down computed channel props
This allows channel headers to reference channel mentions for a client
that doesn't already know about the channels in question.
We intentionally don't send down the props for the autocomplete and
search endpoints since they aren't used in that context, and would add
unnecessary overhead.
* update channel props on patch
* revert to treating channel purpose as plaintext
Diffstat (limited to 'model/channel.go')
-rw-r--r-- | model/channel.go | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/model/channel.go b/model/channel.go index 5617240e6..7a57496ae 100644 --- a/model/channel.go +++ b/model/channel.go @@ -32,21 +32,22 @@ const ( ) type Channel struct { - Id string `json:"id"` - CreateAt int64 `json:"create_at"` - UpdateAt int64 `json:"update_at"` - DeleteAt int64 `json:"delete_at"` - TeamId string `json:"team_id"` - Type string `json:"type"` - DisplayName string `json:"display_name"` - Name string `json:"name"` - Header string `json:"header"` - Purpose string `json:"purpose"` - LastPostAt int64 `json:"last_post_at"` - TotalMsgCount int64 `json:"total_msg_count"` - ExtraUpdateAt int64 `json:"extra_update_at"` - CreatorId string `json:"creator_id"` - SchemeId *string `json:"scheme_id"` + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + TeamId string `json:"team_id"` + Type string `json:"type"` + DisplayName string `json:"display_name"` + Name string `json:"name"` + Header string `json:"header"` + Purpose string `json:"purpose"` + LastPostAt int64 `json:"last_post_at"` + TotalMsgCount int64 `json:"total_msg_count"` + ExtraUpdateAt int64 `json:"extra_update_at"` + CreatorId string `json:"creator_id"` + SchemeId *string `json:"scheme_id"` + Props map[string]interface{} `json:"props" db:"-"` } type ChannelPatch struct { @@ -163,6 +164,18 @@ func (o *Channel) Patch(patch *ChannelPatch) { } } +func (o *Channel) MakeNonNil() { + if o.Props == nil { + o.Props = make(map[string]interface{}) + } +} + +func (o *Channel) AddProp(key string, value interface{}) { + o.MakeNonNil() + + o.Props[key] = value +} + func GetDMNameFromIds(userId1, userId2 string) string { if userId1 > userId2 { return userId2 + "__" + userId1 |