diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/channel_member.go | 58 | ||||
-rw-r--r-- | model/channel_member_test.go | 18 | ||||
-rw-r--r-- | model/client.go | 4 | ||||
-rw-r--r-- | model/config.go | 1 | ||||
-rw-r--r-- | model/post.go | 5 | ||||
-rw-r--r-- | model/post_test.go | 13 | ||||
-rw-r--r-- | model/session.go | 1 | ||||
-rw-r--r-- | model/utils.go | 1 | ||||
-rw-r--r-- | model/version.go | 4 |
9 files changed, 82 insertions, 23 deletions
diff --git a/model/channel_member.go b/model/channel_member.go index 50f51304b..3ae612700 100644 --- a/model/channel_member.go +++ b/model/channel_member.go @@ -10,22 +10,24 @@ import ( ) const ( - CHANNEL_ROLE_ADMIN = "admin" - CHANNEL_NOTIFY_ALL = "all" - CHANNEL_NOTIFY_MENTION = "mention" - CHANNEL_NOTIFY_NONE = "none" - CHANNEL_NOTIFY_QUIET = "quiet" + CHANNEL_ROLE_ADMIN = "admin" + CHANNEL_NOTIFY_DEFAULT = "default" + CHANNEL_NOTIFY_ALL = "all" + CHANNEL_NOTIFY_MENTION = "mention" + CHANNEL_NOTIFY_NONE = "none" + CHANNEL_MARK_UNREAD_ALL = "all" + CHANNEL_MARK_UNREAD_MENTION = "mention" ) 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"` - 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"` + LastUpdateAt int64 `json:"last_update_at"` } func (o *ChannelMember) ToJson() string { @@ -64,8 +66,14 @@ func (o *ChannelMember) IsValid() *AppError { } } - if len(o.NotifyLevel) > 20 || !IsChannelNotifyLevelValid(o.NotifyLevel) { - return NewAppError("ChannelMember.IsValid", "Invalid notify level", "notify_level="+o.NotifyLevel) + notifyLevel := o.NotifyProps["desktop"] + if len(notifyLevel) > 20 || !IsChannelNotifyLevelValid(notifyLevel) { + return NewAppError("ChannelMember.IsValid", "Invalid notify level", "notify_level="+notifyLevel) + } + + 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 @@ -75,6 +83,24 @@ func (o *ChannelMember) PreSave() { o.LastUpdateAt = GetMillis() } +func (o *ChannelMember) PreUpdate() { + o.LastUpdateAt = GetMillis() +} + func IsChannelNotifyLevelValid(notifyLevel string) bool { - return notifyLevel == CHANNEL_NOTIFY_ALL || notifyLevel == CHANNEL_NOTIFY_MENTION || notifyLevel == CHANNEL_NOTIFY_NONE || notifyLevel == CHANNEL_NOTIFY_QUIET + return notifyLevel == CHANNEL_NOTIFY_DEFAULT || + notifyLevel == CHANNEL_NOTIFY_ALL || + notifyLevel == CHANNEL_NOTIFY_MENTION || + notifyLevel == CHANNEL_NOTIFY_NONE +} + +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, + } } diff --git a/model/channel_member_test.go b/model/channel_member_test.go index 3b64ffbf7..edbb46e9b 100644 --- a/model/channel_member_test.go +++ b/model/channel_member_test.go @@ -31,24 +31,34 @@ func TestChannelMemberIsValid(t *testing.T) { } o.Roles = "missing" - o.NotifyLevel = CHANNEL_NOTIFY_ALL + o.NotifyProps = GetDefaultChannelNotifyProps() o.UserId = NewId() if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.Roles = CHANNEL_ROLE_ADMIN - o.NotifyLevel = "junk" + o.NotifyProps["desktop"] = "junk" if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.NotifyLevel = "123456789012345678901" + o.NotifyProps["desktop"] = "123456789012345678901" if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.NotifyLevel = CHANNEL_NOTIFY_ALL + o.NotifyProps["desktop"] = CHANNEL_NOTIFY_ALL + if err := o.IsValid(); err != nil { + t.Fatal(err) + } + + o.NotifyProps["mark_unread"] = "123456789012345678901" + if err := o.IsValid(); err == nil { + t.Fatal("should be invalid") + } + + o.NotifyProps["mark_unread"] = CHANNEL_MARK_UNREAD_ALL if err := o.IsValid(); err != nil { t.Fatal(err) } diff --git a/model/client.go b/model/client.go index 26e00864d..a291cc4f2 100644 --- a/model/client.go +++ b/model/client.go @@ -450,8 +450,8 @@ func (c *Client) UpdateChannelDesc(data map[string]string) (*Result, *AppError) } } -func (c *Client) UpdateNotifyLevel(data map[string]string) (*Result, *AppError) { - if r, err := c.DoApiPost("/channels/update_notify_level", MapToJson(data)); err != nil { +func (c *Client) UpdateNotifyProps(data map[string]string) (*Result, *AppError) { + if r, err := c.DoApiPost("/channels/update_notify_props", MapToJson(data)); err != nil { return nil, err } else { return &Result{r.Header.Get(HEADER_REQUEST_ID), diff --git a/model/config.go b/model/config.go index e3904cc49..c67b36063 100644 --- a/model/config.go +++ b/model/config.go @@ -112,6 +112,7 @@ type RateLimitSettings struct { type PrivacySettings struct { ShowEmailAddress bool ShowFullName bool + EnableDiagnostic bool } type TeamSettings struct { diff --git a/model/post.go b/model/post.go index e78469940..1fc5963c3 100644 --- a/model/post.go +++ b/model/post.go @@ -120,7 +120,10 @@ func (o *Post) PreSave() { o.OriginalId = "" - o.CreateAt = GetMillis() + if o.CreateAt == 0 { + o.CreateAt = GetMillis() + } + o.UpdateAt = o.CreateAt if o.Props == nil { diff --git a/model/post_test.go b/model/post_test.go index 38f4b4c98..a6b880fa0 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -83,5 +83,18 @@ func TestPostIsValid(t *testing.T) { func TestPostPreSave(t *testing.T) { o := Post{Message: "test"} o.PreSave() + + if o.CreateAt == 0 { + t.Fatal("should be set") + } + + past := GetMillis() - 1 + o = Post{Message: "test", CreateAt: past} + o.PreSave() + + if o.CreateAt > past { + t.Fatal("should not be updated") + } + o.Etag() } diff --git a/model/session.go b/model/session.go index 3c7c75eb4..bb4d987a7 100644 --- a/model/session.go +++ b/model/session.go @@ -10,6 +10,7 @@ import ( const ( SESSION_TOKEN = "MMSID" + MULTI_SESSION_TOKEN = "MMSIDMU" SESSION_TIME_WEB_IN_DAYS = 30 SESSION_TIME_WEB_IN_SECS = 60 * 60 * 24 * SESSION_TIME_WEB_IN_DAYS SESSION_TIME_MOBILE_IN_DAYS = 30 diff --git a/model/utils.go b/model/utils.go index e19cceba5..93b8c4512 100644 --- a/model/utils.go +++ b/model/utils.go @@ -163,6 +163,7 @@ var reservedName = []string{ "post", "cluster", "api", + "oauth", } var wwwStart = regexp.MustCompile(`^www`) diff --git a/model/version.go b/model/version.go index 233fc3747..efa1697db 100644 --- a/model/version.go +++ b/model/version.go @@ -67,6 +67,10 @@ func GetPreviousVersion(currentVersion string) (int64, int64) { return 0, 0 } +func IsOfficalBuild() bool { + return BuildNumber != "_BUILD_NUMBER_" +} + func IsCurrentVersion(versionToCheck string) bool { currentMajor, currentMinor, _ := SplitVersion(CurrentVersion) toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck) |