summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/channel.go5
-rw-r--r--model/channel_test.go20
-rw-r--r--model/client.go9
3 files changed, 34 insertions, 0 deletions
diff --git a/model/channel.go b/model/channel.go
index caf1bfd80..ac54a7e44 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -25,6 +25,7 @@ type Channel struct {
DisplayName string `json:"display_name"`
Name string `json:"name"`
Header string `json:"header"`
+ Purpose string `json:"purpose"`
LastPostAt int64 `json:"last_post_at"`
TotalMsgCount int64 `json:"total_msg_count"`
ExtraUpdateAt int64 `json:"extra_update_at"`
@@ -93,6 +94,10 @@ func (o *Channel) IsValid() *AppError {
return NewAppError("Channel.IsValid", "Invalid header", "id="+o.Id)
}
+ if len(o.Purpose) > 128 {
+ return NewAppError("Channel.IsValid", "Invalid purpose", "id="+o.Id)
+ }
+
if len(o.CreatorId) > 26 {
return NewAppError("Channel.IsValid", "Invalid creator id", "")
}
diff --git a/model/channel_test.go b/model/channel_test.go
index e5dfa3734..590417cfe 100644
--- a/model/channel_test.go
+++ b/model/channel_test.go
@@ -67,6 +67,26 @@ func TestChannelIsValid(t *testing.T) {
if err := o.IsValid(); err != nil {
t.Fatal(err)
}
+
+ o.Header = strings.Repeat("01234567890", 100)
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.Header = "1234"
+ if err := o.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+
+ o.Purpose = strings.Repeat("01234567890", 20)
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.Purpose = "1234"
+ if err := o.IsValid(); err != nil {
+ t.Fatal(err)
+ }
}
func TestChannelPreSave(t *testing.T) {
diff --git a/model/client.go b/model/client.go
index c788ead67..8ca5c3bfb 100644
--- a/model/client.go
+++ b/model/client.go
@@ -452,6 +452,15 @@ func (c *Client) UpdateChannelHeader(data map[string]string) (*Result, *AppError
}
}
+func (c *Client) UpdateChannelPurpose(data map[string]string) (*Result, *AppError) {
+ if r, err := c.DoApiPost("/channels/update_purpose", MapToJson(data)); err != nil {
+ return nil, err
+ } else {
+ return &Result{r.Header.Get(HEADER_REQUEST_ID),
+ r.Header.Get(HEADER_ETAG_SERVER), ChannelFromJson(r.Body)}, 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