diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
commit | ea71731f838fc010cfc7511c09875184d1b2396b (patch) | |
tree | 7841e6908a42badb5171760426d2ca5898a76bda /model/client.go | |
parent | 6b534f1b0dae2614ec267a82f1c4dc1b096b7b1c (diff) | |
parent | 5478ea34e436109ece417c3704a1fa36d3aba4a5 (diff) | |
download | chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.gz chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.bz2 chat-ea71731f838fc010cfc7511c09875184d1b2396b.zip |
merging
Diffstat (limited to 'model/client.go')
-rw-r--r-- | model/client.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/model/client.go b/model/client.go index a4da6d513..21b8d8f7a 100644 --- a/model/client.go +++ b/model/client.go @@ -56,7 +56,7 @@ func (c *Client) DoPost(url, data, contentType string) (*http.Response, *AppErro rq.Header.Set("Content-Type", contentType) if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode >= 300 { return nil, AppErrorFromJson(rp.Body) } else { @@ -72,7 +72,7 @@ func (c *Client) DoApiPost(url string, data string) (*http.Response, *AppError) } if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode >= 300 { return nil, AppErrorFromJson(rp.Body) } else { @@ -92,7 +92,7 @@ func (c *Client) DoApiGet(url string, data string, etag string) (*http.Response, } if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode == 304 { return rp, nil } else if rp.StatusCode >= 300 { @@ -298,7 +298,7 @@ func (c *Client) login(m map[string]string) (*Result, *AppError) { sessionToken := getCookie(SESSION_COOKIE_TOKEN, r) if c.AuthToken != sessionToken.Value { - NewAppError("/users/login", "Authentication tokens didn't match", "") + NewLocAppError("/users/login", "model.client.login.app_error", nil, "") } return &Result{r.Header.Get(HEADER_REQUEST_ID), @@ -479,7 +479,7 @@ func (c *Client) TestEmail(config *Config) (*Result, *AppError) { } } -func (c *Client) GetAnalytics(teamId, name string) (*Result, *AppError) { +func (c *Client) GetTeamAnalytics(teamId, name string) (*Result, *AppError) { if r, err := c.DoApiGet("/admin/analytics/"+teamId+"/"+name, "", ""); err != nil { return nil, err } else { @@ -488,6 +488,15 @@ func (c *Client) GetAnalytics(teamId, name string) (*Result, *AppError) { } } +func (c *Client) GetSystemAnalytics(name string) (*Result, *AppError) { + if r, err := c.DoApiGet("/admin/analytics/"+name, "", ""); err != nil { + return nil, err + } else { + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), AnalyticsRowsFromJson(r.Body)}, nil + } +} + func (c *Client) CreateChannel(channel *Channel) (*Result, *AppError) { if r, err := c.DoApiPost("/channels/create", channel.ToJson()); err != nil { return nil, err @@ -735,7 +744,7 @@ func (c *Client) UploadFile(url string, data []byte, contentType string) (*Resul } if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode >= 300 { return nil, AppErrorFromJson(rp.Body) } else { @@ -757,7 +766,7 @@ func (c *Client) GetFile(url string, isFullUrl bool) (*Result, *AppError) { } if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode >= 300 { return nil, AppErrorFromJson(rp.Body) } else { @@ -775,7 +784,7 @@ func (c *Client) GetFileInfo(url string) (*Result, *AppError) { } if rp, err := c.HttpClient.Do(rq); err != nil { - return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error()) } else if rp.StatusCode >= 300 { return nil, AppErrorFromJson(rp.Body) } else { |