[MM-37716] Drop support for LHS specific bot icons (#18087)

Этот коммит содержится в:
Ben Schumacher
2021-08-12 00:27:35 +02:00
коммит произвёл GitHub
родитель 99bb6084b3
Коммит 225565f412
13 изменённых файлов: 0 добавлений и 1013 удалений

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

@@ -1858,72 +1858,6 @@ func (c *Client4) AssignBot(botUserId, newOwnerId string) (*Bot, *Response) {
return bot, BuildResponse(r)
}
// SetBotIconImage sets LHS bot icon image.
func (c *Client4) SetBotIconImage(botUserId string, data []byte) (bool, *Response) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("image", "icon.svg")
if err != nil {
return false, &Response{Error: NewAppError("SetBotIconImage", "model.client.set_bot_icon_image.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
}
if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
return false, &Response{Error: NewAppError("SetBotIconImage", "model.client.set_bot_icon_image.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
}
if err = writer.Close(); err != nil {
return false, &Response{Error: NewAppError("SetBotIconImage", "model.client.set_bot_icon_image.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
}
rq, err := http.NewRequest("POST", c.ApiUrl+c.GetBotRoute(botUserId)+"/icon", bytes.NewReader(body.Bytes()))
if err != nil {
return false, &Response{Error: NewAppError("SetBotIconImage", "model.client.connecting.app_error", nil, err.Error(), http.StatusBadRequest)}
}
rq.Header.Set("Content-Type", writer.FormDataContentType())
if c.AuthToken != "" {
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
}
rp, err := c.HttpClient.Do(rq)
if err != nil || rp == nil {
return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetBotRoute(botUserId)+"/icon", "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
}
defer closeBody(rp)
if rp.StatusCode >= 300 {
return false, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
}
return CheckStatusOK(rp), BuildResponse(rp)
}
// GetBotIconImage gets LHS bot icon image. Must be logged in.
func (c *Client4) GetBotIconImage(botUserId string) ([]byte, *Response) {
r, appErr := c.DoApiGet(c.GetBotRoute(botUserId)+"/icon", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
data, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, BuildErrorResponse(r, NewAppError("GetBotIconImage", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
}
return data, BuildResponse(r)
}
// DeleteBotIconImage deletes LHS bot icon image. Must be logged in.
func (c *Client4) DeleteBotIconImage(botUserId string) (bool, *Response) {
r, appErr := c.DoApiDelete(c.GetBotRoute(botUserId) + "/icon")
if appErr != nil {
return false, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return CheckStatusOK(r), BuildResponse(r)
}
// Team Section
// CreateTeam creates a team in the system based on the provided team struct.