From 0e7a149982f73919badd9d366d06fa699925c89f Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 6 Jan 2016 18:04:24 -0500 Subject: Added the ability to get more channel members from getChannelExtraInfo --- model/channel.go | 4 ++-- model/client.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'model') 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 f1773f3c7..14746f8ae 100644 --- a/model/client.go +++ b/model/client.go @@ -591,8 +591,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), -- cgit v1.2.3-1-g7c22 From b1251b93932adf616a996725448d0b77fad0d3c1 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 11 Jan 2016 09:12:51 -0600 Subject: Upgrade logging package --- model/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'model') diff --git a/model/client.go b/model/client.go index 14746f8ae..75b93c971 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" -- cgit v1.2.3-1-g7c22 From 5083a3947ac792bf668a3c0af545b86c3331a748 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 11 Jan 2016 13:04:55 -0600 Subject: Release 1.4 rc1 --- model/version.go | 1 + 1 file changed, 1 insertion(+) (limited to 'model') diff --git a/model/version.go b/model/version.go index 142ddb371..88334ceea 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", -- cgit v1.2.3-1-g7c22 From 9110dd54a15f3d0fcf6f60936e01d816b667b93c Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 4 Jan 2016 12:44:22 -0500 Subject: Added license validation and settings --- model/license.go | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 model/license.go (limited to 'model') diff --git a/model/license.go b/model/license.go new file mode 100644 index 000000000..7a955e1f8 --- /dev/null +++ b/model/license.go @@ -0,0 +1,68 @@ +// Copyright (c) 2015 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 (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 + } +} -- cgit v1.2.3-1-g7c22 From 874d120535a615afddeb80599b7d2d982959ffdb Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Wed, 13 Jan 2016 10:54:12 -0500 Subject: Add some unit tests --- model/license.go | 2 +- model/license_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 model/license_test.go (limited to 'model') diff --git a/model/license.go b/model/license.go index 7a955e1f8..20e49d668 100644 --- a/model/license.go +++ b/model/license.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. package model 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") + } +} -- cgit v1.2.3-1-g7c22 From c26edcf6786fd8aa1535c09e9581fc6417cddda4 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 14 Jan 2016 08:23:48 -0500 Subject: Final updates --- model/license.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'model') diff --git a/model/license.go b/model/license.go index 20e49d668..a271b46b7 100644 --- a/model/license.go +++ b/model/license.go @@ -26,9 +26,26 @@ type Customer struct { } type Features struct { - Users int `json:"users"` - LDAP bool `json:"ldap"` - GoogleSSO bool `json:"google_sso"` + 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 { -- cgit v1.2.3-1-g7c22