summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-01-14 09:08:13 -0600
committer=Corey Hulen <corey@hulen.com>2016-01-14 09:08:13 -0600
commit6d6cada0970a2b341f36dac9b0fed8262ada1865 (patch)
treefc3728f15deaebd0c870838a63735659a33456e7 /model
parent0b986ed3147c885af6b2f33e1ff3eb6754e8f274 (diff)
parenta341dbad2b8a4564b6f270c79f2f9932e499ac80 (diff)
downloadchat-6d6cada0970a2b341f36dac9b0fed8262ada1865.tar.gz
chat-6d6cada0970a2b341f36dac9b0fed8262ada1865.tar.bz2
chat-6d6cada0970a2b341f36dac9b0fed8262ada1865.zip
Merge branch 'master' into PLT-1429
Diffstat (limited to 'model')
-rw-r--r--model/channel.go4
-rw-r--r--model/client.go6
-rw-r--r--model/license.go85
-rw-r--r--model/license_test.go34
-rw-r--r--model/version.go1
5 files changed, 125 insertions, 5 deletions
diff --git a/model/channel.go b/model/channel.go
index 0ce09f4bc..7109500d4 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -57,8 +57,8 @@ func (o *Channel) Etag() string {
return Etag(o.Id, o.UpdateAt)
}
-func (o *Channel) ExtraEtag() string {
- return Etag(o.Id, o.ExtraUpdateAt)
+func (o *Channel) ExtraEtag(memberLimit int) string {
+ return Etag(o.Id, o.ExtraUpdateAt, memberLimit)
}
func (o *Channel) IsValid() *AppError {
diff --git a/model/client.go b/model/client.go
index 3a645e175..a4da6d513 100644
--- a/model/client.go
+++ b/model/client.go
@@ -5,8 +5,8 @@ package model
import (
"bytes"
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"io/ioutil"
"net/http"
"net/url"
@@ -636,8 +636,8 @@ func (c *Client) UpdateLastViewedAt(channelId string) (*Result, *AppError) {
}
}
-func (c *Client) GetChannelExtraInfo(id string, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/channels/"+id+"/extra_info", "", etag); err != nil {
+func (c *Client) GetChannelExtraInfo(id string, memberLimit int, etag string) (*Result, *AppError) {
+ if r, err := c.DoApiGet("/channels/"+id+"/extra_info/"+strconv.FormatInt(int64(memberLimit), 10), "", etag); err != nil {
return nil, err
} else {
return &Result{r.Header.Get(HEADER_REQUEST_ID),
diff --git a/model/license.go b/model/license.go
new file mode 100644
index 000000000..a271b46b7
--- /dev/null
+++ b/model/license.go
@@ -0,0 +1,85 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type License struct {
+ Id string `json:"id"`
+ IssuedAt int64 `json:"issued_at"`
+ StartsAt int64 `json:"starts_at"`
+ ExpiresAt int64 `json:"expires_at"`
+ Customer *Customer `json:"customer"`
+ Features *Features `json:"features"`
+}
+
+type Customer struct {
+ Id string `json:"id"`
+ Name string `json:"name"`
+ Email string `json:"email"`
+ Company string `json:"company"`
+ PhoneNumber string `json:"phone_number"`
+}
+
+type Features struct {
+ Users *int `json:"users"`
+ LDAP *bool `json:"ldap"`
+ GoogleSSO *bool `json:"google_sso"`
+}
+
+func (f *Features) SetDefaults() {
+ if f.Users == nil {
+ f.Users = new(int)
+ *f.Users = 0
+ }
+
+ if f.LDAP == nil {
+ f.LDAP = new(bool)
+ *f.LDAP = true
+ }
+
+ if f.GoogleSSO == nil {
+ f.GoogleSSO = new(bool)
+ *f.GoogleSSO = true
+ }
+}
+
+func (l *License) IsExpired() bool {
+ now := GetMillis()
+ if l.ExpiresAt < now {
+ return true
+ }
+ return false
+}
+
+func (l *License) IsStarted() bool {
+ now := GetMillis()
+ if l.StartsAt < now {
+ return true
+ }
+ return false
+}
+
+func (l *License) ToJson() string {
+ b, err := json.Marshal(l)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func LicenseFromJson(data io.Reader) *License {
+ decoder := json.NewDecoder(data)
+ var o License
+ err := decoder.Decode(&o)
+ if err == nil {
+ return &o
+ } else {
+ return nil
+ }
+}
diff --git a/model/license_test.go b/model/license_test.go
new file mode 100644
index 000000000..25c74a2e3
--- /dev/null
+++ b/model/license_test.go
@@ -0,0 +1,34 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "testing"
+)
+
+func TestLicenseExpired(t *testing.T) {
+ l1 := License{}
+ l1.ExpiresAt = GetMillis() - 1000
+ if !l1.IsExpired() {
+ t.Fatal("license should be expired")
+ }
+
+ l1.ExpiresAt = GetMillis() + 10000
+ if l1.IsExpired() {
+ t.Fatal("license should not be expired")
+ }
+}
+
+func TestLicenseStarted(t *testing.T) {
+ l1 := License{}
+ l1.StartsAt = GetMillis() - 1000
+ if !l1.IsStarted() {
+ t.Fatal("license should be started")
+ }
+
+ l1.StartsAt = GetMillis() + 10000
+ if l1.IsStarted() {
+ t.Fatal("license should not be started")
+ }
+}
diff --git a/model/version.go b/model/version.go
index e6faf137c..4a642d017 100644
--- a/model/version.go
+++ b/model/version.go
@@ -12,6 +12,7 @@ import (
// It should be maitained in chronological order with most current
// release at the front of the list.
var versions = []string{
+ "1.4.0",
"1.3.0",
"1.2.1",
"1.2.0",