GH-9633 Added plugin API method to return user's profile image (#9653)

Этот коммит содержится в:
Alexander Akhmetov
2018-10-15 16:23:41 +02:00
коммит произвёл Carlos Tadeu Panato Junior
родитель c1e5fff565
Коммит 160d278592
5 изменённых файлов: 84 добавлений и 1 удалений

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

@@ -323,6 +323,16 @@ func (api *PluginAPI) UpdatePost(post *model.Post) (*model.Post, *model.AppError
return api.app.UpdatePost(post, false)
}
func (api *PluginAPI) GetProfileImage(userId string) ([]byte, *model.AppError) {
user, err := api.app.GetUser(userId)
if err != nil {
return nil, err
}
data, _, err := api.app.GetProfileImage(user)
return data, err
}
func (api *PluginAPI) CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError) {
return api.app.CopyFileInfos(userId, fileIds)
}

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

@@ -83,7 +83,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
}
type MyPlugin struct {
plugin.MattermostPlugin
plugin.MattermostPlugin
configuration configuration
}
@@ -199,3 +199,19 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
_, ret := hooks.MessageWillBePosted(nil, nil)
assert.Equal(t, "override35true", ret)
}
func TestPluginAPIGetProfileImage(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
api := th.SetupPluginAPI()
// check existing user first
data, err := api.GetProfileImage(th.BasicUser.Id)
require.Nil(t, err)
require.NotEmpty(t, data)
// then unknown user
data, err = api.GetProfileImage(model.NewId())
require.NotNil(t, err)
require.Nil(t, data)
}