github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/model/channel_data.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "encoding/json" 8 "io" 9 ) 10 11 type ChannelData struct { 12 Channel *Channel `json:"channel"` 13 Member *ChannelMember `json:"member"` 14 } 15 16 func (o *ChannelData) Etag() string { 17 var mt int64 = 0 18 if o.Member != nil { 19 mt = o.Member.LastUpdateAt 20 } 21 22 return Etag(o.Channel.Id, o.Channel.UpdateAt, o.Channel.LastPostAt, mt) 23 } 24 25 func (o *ChannelData) ToJson() string { 26 b, _ := json.Marshal(o) 27 return string(b) 28 } 29 30 func ChannelDataFromJson(data io.Reader) *ChannelData { 31 var o *ChannelData 32 json.NewDecoder(data).Decode(&o) 33 return o 34 }