diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/client.go | 22 | ||||
-rw-r--r-- | model/team.go | 14 | ||||
-rw-r--r-- | model/team_signup_test.go | 2 | ||||
-rw-r--r-- | model/team_test.go | 14 | ||||
-rw-r--r-- | model/utils.go | 10 | ||||
-rw-r--r-- | model/utils_test.go | 8 |
6 files changed, 35 insertions, 35 deletions
diff --git a/model/client.go b/model/client.go index ab01e7d62..9a144095a 100644 --- a/model/client.go +++ b/model/client.go @@ -98,10 +98,10 @@ func (c *Client) Must(result *Result, err *AppError) *Result { return result } -func (c *Client) SignupTeam(email string, name string) (*Result, *AppError) { +func (c *Client) SignupTeam(email string, displayName string) (*Result, *AppError) { m := make(map[string]string) m["email"] = email - m["name"] = name + m["display_name"] = displayName if r, err := c.DoPost("/teams/signup", MapToJson(m)); err != nil { return nil, err } else { @@ -128,11 +128,11 @@ func (c *Client) CreateTeam(team *Team) (*Result, *AppError) { } } -func (c *Client) FindTeamByDomain(domain string, allServers bool) (*Result, *AppError) { +func (c *Client) FindTeamByName(name string, allServers bool) (*Result, *AppError) { m := make(map[string]string) - m["domain"] = domain + m["name"] = name m["all"] = fmt.Sprintf("%v", allServers) - if r, err := c.DoPost("/teams/find_team_by_domain", MapToJson(m)); err != nil { + if r, err := c.DoPost("/teams/find_team_by_name", MapToJson(m)); err != nil { return nil, err } else { val := false @@ -177,7 +177,7 @@ func (c *Client) InviteMembers(invites *Invites) (*Result, *AppError) { } } -func (c *Client) UpdateTeamName(data map[string]string) (*Result, *AppError) { +func (c *Client) UpdateTeamDisplayName(data map[string]string) (*Result, *AppError) { if r, err := c.DoPost("/teams/update_name", MapToJson(data)); err != nil { return nil, err } else { @@ -247,17 +247,17 @@ func (c *Client) LoginById(id string, password string) (*Result, *AppError) { return c.login(m) } -func (c *Client) LoginByEmail(domain string, email string, password string) (*Result, *AppError) { +func (c *Client) LoginByEmail(name string, email string, password string) (*Result, *AppError) { m := make(map[string]string) - m["domain"] = domain + m["name"] = name m["email"] = email m["password"] = password return c.login(m) } -func (c *Client) LoginByEmailWithDevice(domain string, email string, password string, deviceId string) (*Result, *AppError) { +func (c *Client) LoginByEmailWithDevice(name string, email string, password string, deviceId string) (*Result, *AppError) { m := make(map[string]string) - m["domain"] = domain + m["name"] = name m["email"] = email m["password"] = password m["device_id"] = deviceId @@ -550,7 +550,7 @@ func (c *Client) GetFile(url string, isFullUrl bool) (*Result, *AppError) { if isFullUrl { rq, _ = http.NewRequest("GET", url, nil) } else { - rq, _ = http.NewRequest("GET", c.Url+url, nil) + rq, _ = http.NewRequest("GET", c.Url+"/files/get"+url, nil) } if len(c.AuthToken) > 0 { diff --git a/model/team.go b/model/team.go index 5c66f3b1f..e7005625b 100644 --- a/model/team.go +++ b/model/team.go @@ -18,8 +18,8 @@ type Team struct { CreateAt int64 `json:"create_at"` UpdateAt int64 `json:"update_at"` DeleteAt int64 `json:"delete_at"` + DisplayName string `json:"display_name"` Name string `json:"name"` - Domain string `json:"domain"` Email string `json:"email"` Type string `json:"type"` CompanyName string `json:"company_name"` @@ -97,20 +97,20 @@ func (o *Team) IsValid() *AppError { return NewAppError("Team.IsValid", "Invalid email", "id="+o.Id) } - if len(o.Name) > 64 { + if len(o.DisplayName) > 64 { return NewAppError("Team.IsValid", "Invalid name", "id="+o.Id) } - if len(o.Domain) > 64 { - return NewAppError("Team.IsValid", "Invalid domain", "id="+o.Id) + if len(o.Name) > 64 { + return NewAppError("Team.IsValid", "Invalid URL Identifier", "id="+o.Id) } - if IsReservedDomain(o.Domain) { + if IsReservedTeamName(o.Name) { return NewAppError("Team.IsValid", "This URL is unavailable. Please try another.", "id="+o.Id) } - if !IsValidDomain(o.Domain) { - return NewAppError("Team.IsValid", "Domain must be 4 or more lowercase alphanumeric characters", "id="+o.Id) + if !IsValidTeamName(o.Name) { + return NewAppError("Team.IsValid", "Name must be 4 or more lowercase alphanumeric characters", "id="+o.Id) } if !(o.Type == TEAM_OPEN || o.Type == TEAM_INVITE) { diff --git a/model/team_signup_test.go b/model/team_signup_test.go index f3f74470b..eb2fbc69f 100644 --- a/model/team_signup_test.go +++ b/model/team_signup_test.go @@ -9,7 +9,7 @@ import ( ) func TestTeamSignupJson(t *testing.T) { - team := Team{Id: NewId(), Name: NewId()} + team := Team{Id: NewId(), DisplayName: NewId()} o := TeamSignup{Team: team, Data: "data"} json := o.ToJson() ro := TeamSignupFromJson(strings.NewReader(json)) diff --git a/model/team_test.go b/model/team_test.go index 6261ed6bf..071b1a2e9 100644 --- a/model/team_test.go +++ b/model/team_test.go @@ -9,7 +9,7 @@ import ( ) func TestTeamJson(t *testing.T) { - o := Team{Id: NewId(), Name: NewId()} + o := Team{Id: NewId(), DisplayName: NewId()} json := o.ToJson() ro := TeamFromJson(strings.NewReader(json)) @@ -46,18 +46,18 @@ func TestTeamIsValid(t *testing.T) { } o.Email = "corey@hulen.com" - o.Name = strings.Repeat("01234567890", 20) + o.DisplayName = strings.Repeat("01234567890", 20) if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.Name = "1234" - o.Domain = "ZZZZZZZ" + o.DisplayName = "1234" + o.Name = "ZZZZZZZ" if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } - o.Domain = "zzzzz" + o.Name = "zzzzz" o.Type = TEAM_OPEN if err := o.IsValid(); err != nil { t.Fatal(err) @@ -65,12 +65,12 @@ func TestTeamIsValid(t *testing.T) { } func TestTeamPreSave(t *testing.T) { - o := Team{Name: "test"} + o := Team{DisplayName: "test"} o.PreSave() o.Etag() } func TestTeamPreUpdate(t *testing.T) { - o := Team{Name: "test"} + o := Team{DisplayName: "test"} o.PreUpdate() } diff --git a/model/utils.go b/model/utils.go index 465901a09..093a54e38 100644 --- a/model/utils.go +++ b/model/utils.go @@ -148,7 +148,7 @@ func IsValidEmail(email string) bool { return false } -var reservedDomains = []string{ +var reservedName = []string{ "www", "web", "admin", @@ -168,10 +168,10 @@ var reservedDomains = []string{ "api", } -func IsReservedDomain(s string) bool { +func IsReservedTeamName(s string) bool { s = strings.ToLower(s) - for _, value := range reservedDomains { + for _, value := range reservedName { if strings.Index(s, value) == 0 { return true } @@ -180,7 +180,7 @@ func IsReservedDomain(s string) bool { return false } -func IsValidDomain(s string) bool { +func IsValidTeamName(s string) bool { if !IsValidAlphaNum(s) { return false @@ -319,6 +319,6 @@ func ClearMentionTags(post string) string { } var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`) -var PartialUrlRegex = regexp.MustCompile(`/api/v1/files/(get|get_image)/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/(([A-Za-z0-9]+/)?.+\.[A-Za-z0-9]{3,})`) +var PartialUrlRegex = regexp.MustCompile(`/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/((?:[A-Za-z0-9]{26})?.+\.[A-Za-z0-9]{3,})`) var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true, '/': true, '\\': true} diff --git a/model/utils_test.go b/model/utils_test.go index a9721042d..dbb448882 100644 --- a/model/utils_test.go +++ b/model/utils_test.go @@ -83,9 +83,9 @@ var domains = []struct { {"test", true}, } -func TestValidDomain(t *testing.T) { +func TestValidTeamName(t *testing.T) { for _, v := range domains { - if IsValidDomain(v.value) != v.expected { + if IsValidTeamName(v.value) != v.expected { t.Errorf("expect %v as %v", v.value, v.expected) } } @@ -102,9 +102,9 @@ var tReservedDomains = []struct { {"spin-punch-admin", false}, } -func TestReservedDomain(t *testing.T) { +func TestReservedTeamName(t *testing.T) { for _, v := range tReservedDomains { - if IsReservedDomain(v.value) != v.expected { + if IsReservedTeamName(v.value) != v.expected { t.Errorf("expect %v as %v", v.value, v.expected) } } |