summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/model/channel_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/model/channel_list.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/model/channel_list.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/model/channel_list.go b/vendor/github.com/mattermost/mattermost-server/model/channel_list.go
new file mode 100644
index 00000000..1b3bda46
--- /dev/null
+++ b/vendor/github.com/mattermost/mattermost-server/model/channel_list.go
@@ -0,0 +1,53 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type ChannelList []*Channel
+
+func (o *ChannelList) ToJson() string {
+ if b, err := json.Marshal(o); err != nil {
+ return "[]"
+ } else {
+ return string(b)
+ }
+}
+
+func (o *ChannelList) Etag() string {
+
+ id := "0"
+ var t int64 = 0
+ var delta int64 = 0
+
+ for _, v := range *o {
+ if v.LastPostAt > t {
+ t = v.LastPostAt
+ id = v.Id
+ }
+
+ if v.UpdateAt > t {
+ t = v.UpdateAt
+ id = v.Id
+ }
+
+ }
+
+ return Etag(id, t, delta, len(*o))
+}
+
+func ChannelListFromJson(data io.Reader) *ChannelList {
+ var o *ChannelList
+ json.NewDecoder(data).Decode(&o)
+ return o
+}
+
+func ChannelSliceFromJson(data io.Reader) []*Channel {
+ var o []*Channel
+ json.NewDecoder(data).Decode(&o)
+ return o
+}