[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 удалений

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

@@ -3265,6 +3265,17 @@ func TestSetProfileImage(t *testing.T) {
ruser, appErr := th.App.GetUser(user.Id)
require.Nil(t, appErr)
assert.True(t, buser.LastPictureUpdate == ruser.LastPictureUpdate, "Same picture should not have updated")
data2, err := testutils.ReadTestFile("testjpg.jpg")
require.NoError(t, err)
_, resp = th.SystemAdminClient.SetProfileImage(user.Id, data2)
CheckNoError(t, resp)
ruser, appErr = th.App.GetUser(user.Id)
require.Nil(t, appErr)
assert.True(t, buser.LastPictureUpdate < ruser.LastPictureUpdate, "Picture should have updated for user")
info := &model.FileInfo{Path: "users/" + user.Id + "/profile.png"}