PLT-7025: Fix Slack Import API. (#6905)

This commit is contained in:
George Goldberg
2017-07-12 14:13:25 +01:00
committed by Saturnino Abril
parent e975b84a12
commit 2bf64b54c2
5 changed files with 19 additions and 15 deletions

View File

@@ -352,7 +352,7 @@ func (c *Client4) DoEmojiUploadFile(url string, data []byte, contentType string)
}
}
func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string) ([]byte, *Response) {
func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string) (map[string]string, *Response) {
rq, _ := http.NewRequest("POST", c.ApiUrl+url, bytes.NewReader(data))
rq.Header.Set("Content-Type", contentType)
rq.Close = true
@@ -365,11 +365,9 @@ func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string
return nil, &Response{Error: NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)}
} else if rp.StatusCode >= 300 {
return nil, &Response{StatusCode: rp.StatusCode, Error: AppErrorFromJson(rp.Body)}
} else if data, err := ioutil.ReadAll(rp.Body); err != nil {
return nil, &Response{StatusCode: rp.StatusCode, Error: NewAppError("UploadImportTeam", "model.client.read_file.app_error", nil, err.Error(), rp.StatusCode)}
} else {
defer closeBody(rp)
return data, BuildResponse(rp)
return MapFromJson(rp.Body), BuildResponse(rp)
}
}
@@ -1210,7 +1208,7 @@ func (c *Client4) GetTeamUnread(teamId, userId string) (*TeamUnread, *Response)
}
// ImportTeam will import an exported team from other app into a existing team.
func (c *Client4) ImportTeam(data []byte, filesize int, importFrom, filename, teamId string) ([]byte, *Response) {
func (c *Client4) ImportTeam(data []byte, filesize int, importFrom, filename, teamId string) (map[string]string, *Response) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)