[MM-36318] Set bot profile image and icon only if they have changed (#18008)

* Set bot profile image and icon only if they have changed

* Move equality check to the app layer

* Use ioutil.ReadAll

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Claudio Costa
2021-08-11 09:37:52 +02:00
коммит произвёл GitHub
родитель 2982cc6f4e
Коммит 868b8d91db
5 изменённых файлов: 42 добавлений и 12 удалений

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

@@ -661,8 +661,7 @@ func (api *PluginAPI) GetProfileImage(userID string) ([]byte, *model.AppError) {
}
func (api *PluginAPI) SetProfileImage(userID string, data []byte) *model.AppError {
_, err := api.app.GetUser(userID)
if err != nil {
if _, err := api.app.GetUser(userID); err != nil {
return err
}
@@ -949,10 +948,6 @@ func (api *PluginAPI) GetBotIconImage(userID string) ([]byte, *model.AppError) {
}
func (api *PluginAPI) SetBotIconImage(userID string, data []byte) *model.AppError {
if _, err := api.app.GetBot(userID, true); err != nil {
return err
}
return api.app.SetBotIconImage(userID, bytes.NewReader(data))
}