From c16b9de8dc4924cf2fb243579284e67f55cf3a47 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 30 Sep 2015 11:08:36 -0400 Subject: Replaced ChannelMember.MarkUnreadLevel with ChannelMember.NotifyProps --- model/channel_member.go | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'model/channel_member.go') diff --git a/model/channel_member.go b/model/channel_member.go index 58c73d54a..f4a9a9836 100644 --- a/model/channel_member.go +++ b/model/channel_member.go @@ -20,15 +20,15 @@ const ( ) type ChannelMember struct { - ChannelId string `json:"channel_id"` - UserId string `json:"user_id"` - Roles string `json:"roles"` - LastViewedAt int64 `json:"last_viewed_at"` - MsgCount int64 `json:"msg_count"` - MentionCount int64 `json:"mention_count"` - NotifyLevel string `json:"notify_level"` - MarkUnreadLevel string `json:"mark_unread_level"` - LastUpdateAt int64 `json:"last_update_at"` + ChannelId string `json:"channel_id"` + UserId string `json:"user_id"` + Roles string `json:"roles"` + LastViewedAt int64 `json:"last_viewed_at"` + MsgCount int64 `json:"msg_count"` + MentionCount int64 `json:"mention_count"` + NotifyProps StringMap `json:"notify_props"` + NotifyLevel string `json:"notify_level"` + LastUpdateAt int64 `json:"last_update_at"` } func (o *ChannelMember) ToJson() string { @@ -71,8 +71,9 @@ func (o *ChannelMember) IsValid() *AppError { return NewAppError("ChannelMember.IsValid", "Invalid notify level", "notify_level="+o.NotifyLevel) } - if len(o.MarkUnreadLevel) > 20 || !IsChannelMarkUnreadLevelValid(o.MarkUnreadLevel) { - return NewAppError("ChannelMember.IsValid", "Invalid mark unread level", "mark_unread_level="+o.MarkUnreadLevel) + markUnreadLevel := o.NotifyProps["mark_unread"] + if len(markUnreadLevel) > 20 || !IsChannelMarkUnreadLevelValid(markUnreadLevel) { + return NewAppError("ChannelMember.IsValid", "Invalid mark unread level", "mark_unread_level="+markUnreadLevel) } return nil @@ -82,6 +83,10 @@ func (o *ChannelMember) PreSave() { o.LastUpdateAt = GetMillis() } +func (o *ChannelMember) PreUpdate() { + o.LastUpdateAt = GetMillis() +} + func IsChannelNotifyLevelValid(notifyLevel string) bool { return notifyLevel == CHANNEL_NOTIFY_DEFAULT || notifyLevel == CHANNEL_NOTIFY_ALL || @@ -92,3 +97,10 @@ func IsChannelNotifyLevelValid(notifyLevel string) bool { func IsChannelMarkUnreadLevelValid(markUnreadLevel string) bool { return markUnreadLevel == CHANNEL_MARK_UNREAD_ALL || markUnreadLevel == CHANNEL_MARK_UNREAD_MENTION } + +func GetDefaultChannelNotifyProps() StringMap { + return StringMap{ + "desktop": CHANNEL_NOTIFY_DEFAULT, + "mark_unread": CHANNEL_MARK_UNREAD_ALL, + } +} -- cgit v1.2.3-1-g7c22