diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-09-29 11:45:59 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-09-29 08:45:59 -0700 |
commit | 8b9dbb86133ff0fd6002a391268383d1593918ca (patch) | |
tree | b8399f2bae881afe12f3bdb34ec725e97307144a /model/channel_view.go | |
parent | 5e50d3f4612dc8e6dffeff268f024a3d383a329c (diff) | |
download | chat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.gz chat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.bz2 chat-8b9dbb86133ff0fd6002a391268383d1593918ca.zip |
PLT-7404 Return viewed at times in view channel API response (#7428)
* Return viewed at times in view channel API response
* Updated transaction to read and write once
* Remove transaction and only update if new value greater than older
Diffstat (limited to 'model/channel_view.go')
-rw-r--r-- | model/channel_view.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/model/channel_view.go b/model/channel_view.go index 8a7ead76f..e7b1de306 100644 --- a/model/channel_view.go +++ b/model/channel_view.go @@ -32,3 +32,28 @@ func ChannelViewFromJson(data io.Reader) *ChannelView { return nil } } + +type ChannelViewResponse struct { + Status string `json:"status"` + LastViewedAtTimes map[string]int64 `json:"last_viewed_at_times"` +} + +func (o *ChannelViewResponse) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func ChannelViewResponseFromJson(data io.Reader) *ChannelViewResponse { + decoder := json.NewDecoder(data) + var o ChannelViewResponse + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |