Merge branch 'master' into PLT-1429

Этот коммит содержится в:
=Corey Hulen
2016-01-14 09:08:13 -06:00
родитель 0b986ed314 a341dbad2b
Коммит 6d6cada097
104 изменённых файлов: 1941 добавлений и 848 удалений

Просмотреть файл

@@ -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 {

Просмотреть файл

@@ -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),

85
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
}
}

34
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")
}
}

Просмотреть файл

@@ -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",