summaryrefslogtreecommitdiffstats
path: root/model/channel_member.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-09-30 11:08:36 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-01 08:31:11 -0400
commitc16b9de8dc4924cf2fb243579284e67f55cf3a47 (patch)
treed7780fae809cec0b021281638f25ed7920050b0a /model/channel_member.go
parent111fbb2495e88d69bec29971da8ddf086ac3f3b6 (diff)
downloadchat-c16b9de8dc4924cf2fb243579284e67f55cf3a47.tar.gz
chat-c16b9de8dc4924cf2fb243579284e67f55cf3a47.tar.bz2
chat-c16b9de8dc4924cf2fb243579284e67f55cf3a47.zip
Replaced ChannelMember.MarkUnreadLevel with ChannelMember.NotifyProps
Diffstat (limited to 'model/channel_member.go')
-rw-r--r--model/channel_member.go34
1 files changed, 23 insertions, 11 deletions
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,
+ }
+}