diff options
author | Wim <wim@42.be> | 2016-11-12 22:00:53 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-12 22:00:53 +0100 |
commit | 1d5cd1d7c479c382c9cddaf02f1e59bf55971f12 (patch) | |
tree | abaf22fc41326750e376f0831537bbbbe769d5b2 /vendor/github.com/mattermost/platform/model/channel_member.go | |
parent | 08ebee6b4faf677da159db1cffea292050492fd5 (diff) | |
download | matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.tar.gz matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.tar.bz2 matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.zip |
Sync with mattermost 3.5.0
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/channel_member.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/channel_member.go | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/vendor/github.com/mattermost/platform/model/channel_member.go b/vendor/github.com/mattermost/platform/model/channel_member.go index 66e20da6..4180bb8e 100644 --- a/vendor/github.com/mattermost/platform/model/channel_member.go +++ b/vendor/github.com/mattermost/platform/model/channel_member.go @@ -10,7 +10,6 @@ import ( ) const ( - CHANNEL_ROLE_ADMIN = "admin" CHANNEL_NOTIFY_DEFAULT = "default" CHANNEL_NOTIFY_ALL = "all" CHANNEL_NOTIFY_MENTION = "mention" @@ -30,6 +29,27 @@ type ChannelMember struct { LastUpdateAt int64 `json:"last_update_at"` } +type ChannelMembers []ChannelMember + +func (o *ChannelMembers) ToJson() string { + if b, err := json.Marshal(o); err != nil { + return "[]" + } else { + return string(b) + } +} + +func ChannelMembersFromJson(data io.Reader) *ChannelMembers { + decoder := json.NewDecoder(data) + var o ChannelMembers + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} + func (o *ChannelMember) ToJson() string { b, err := json.Marshal(o) if err != nil { @@ -60,12 +80,6 @@ func (o *ChannelMember) IsValid() *AppError { return NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.user_id.app_error", nil, "") } - for _, role := range strings.Split(o.Roles, " ") { - if !(role == "" || role == CHANNEL_ROLE_ADMIN) { - return NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.role.app_error", nil, "role="+role) - } - } - notifyLevel := o.NotifyProps["desktop"] if len(notifyLevel) > 20 || !IsChannelNotifyLevelValid(notifyLevel) { return NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.notify_level.app_error", @@ -89,6 +103,10 @@ func (o *ChannelMember) PreUpdate() { o.LastUpdateAt = GetMillis() } +func (o *ChannelMember) GetRoles() []string { + return strings.Fields(o.Roles) +} + func IsChannelNotifyLevelValid(notifyLevel string) bool { return notifyLevel == CHANNEL_NOTIFY_DEFAULT || notifyLevel == CHANNEL_NOTIFY_ALL || |