summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform/model/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/client.go')
-rw-r--r--vendor/github.com/mattermost/platform/model/client.go40
1 files changed, 21 insertions, 19 deletions
diff --git a/vendor/github.com/mattermost/platform/model/client.go b/vendor/github.com/mattermost/platform/model/client.go
index 564aa2e4..ef890b59 100644
--- a/vendor/github.com/mattermost/platform/model/client.go
+++ b/vendor/github.com/mattermost/platform/model/client.go
@@ -18,6 +18,8 @@ import (
l4g "github.com/alecthomas/log4go"
)
+var UsedApiV3 *int32 = new(int32)
+
const (
HEADER_REQUEST_ID = "X-Request-ID"
HEADER_VERSION_ID = "X-Version-ID"
@@ -37,7 +39,7 @@ const (
STATUS_FAIL = "FAIL"
STATUS_REMOVE = "REMOVE"
- CLIENT_DIR = "webapp/dist"
+ CLIENT_DIR = "client"
API_URL_SUFFIX_V1 = "/api/v1"
API_URL_SUFFIX_V3 = "/api/v3"
@@ -144,7 +146,7 @@ func (c *Client) DoPost(url, data, contentType string) (*http.Response, *AppErro
rq.Close = true
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
defer closeBody(rp)
return nil, AppErrorFromJson(rp.Body)
@@ -162,7 +164,7 @@ func (c *Client) DoApiPost(url string, data string) (*http.Response, *AppError)
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
defer closeBody(rp)
return nil, AppErrorFromJson(rp.Body)
@@ -184,7 +186,7 @@ func (c *Client) DoApiGet(url string, data string, etag string) (*http.Response,
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode == 304 {
return rp, nil
} else if rp.StatusCode >= 300 {
@@ -429,7 +431,7 @@ func (c *Client) UpdateTeam(team *Team) (*Result, *AppError) {
} else {
defer closeBody(r)
return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
+ r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
}
}
@@ -677,7 +679,7 @@ func (c *Client) login(m map[string]string) (*Result, *AppError) {
sessionToken := getCookie(SESSION_COOKIE_TOKEN, r)
if c.AuthToken != sessionToken.Value {
- NewLocAppError("/users/login", "model.client.login.app_error", nil, "")
+ NewAppError("/users/login", "model.client.login.app_error", nil, "", 0)
}
defer closeBody(r)
@@ -1054,7 +1056,7 @@ func (c *Client) DownloadComplianceReport(id string) (*Result, *AppError) {
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError("/admin/download_compliance_report", "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError("/admin/download_compliance_report", "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
defer rp.Body.Close()
return nil, AppErrorFromJson(rp.Body)
@@ -1527,19 +1529,19 @@ func (c *Client) UploadPostAttachment(data []byte, channelId string, filename st
writer := multipart.NewWriter(body)
if part, err := writer.CreateFormFile("files", filename); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error())
+ return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), 0)
} else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error())
+ return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), 0)
}
if part, err := writer.CreateFormField("channel_id"); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error())
+ return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), 0)
} else if _, err = io.Copy(part, strings.NewReader(channelId)); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error())
+ return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), 0)
}
if err := writer.Close(); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.writer.app_error", nil, err.Error())
+ return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.writer.app_error", nil, err.Error(), 0)
}
if result, err := c.uploadFile(c.ApiUrl+c.GetTeamRoute()+"/files/upload", body.Bytes(), writer.FormDataContentType()); err != nil {
@@ -1559,7 +1561,7 @@ func (c *Client) uploadFile(url string, data []byte, contentType string) (*Resul
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
return nil, AppErrorFromJson(rp.Body)
} else {
@@ -2175,17 +2177,17 @@ func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoj
writer := multipart.NewWriter(body)
if part, err := writer.CreateFormFile("image", filename); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)
} else if _, err = io.Copy(part, bytes.NewBuffer(image)); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)
}
if err := writer.WriteField("emoji", emoji.ToJson()); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error(), 0)
}
if err := writer.Close(); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error(), 0)
}
rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetEmojiRoute()+"/create", body)
@@ -2197,7 +2199,7 @@ func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoj
}
if r, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error(), 0)
} else if r.StatusCode >= 300 {
return nil, AppErrorFromJson(r.Body)
} else {
@@ -2241,7 +2243,7 @@ func (c *Client) UploadCertificateFile(data []byte, contentType string) *AppErro
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
return AppErrorFromJson(rp.Body)
} else {