mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Add RemoveTeamIcon plugin api (#9847)
This commit is contained in:
committed by
GitHub
parent
c46d8ec892
commit
2555a5d45d
@@ -510,6 +510,19 @@ func (api *PluginAPI) OpenInteractiveDialog(dialog model.OpenDialogRequest) *mod
|
||||
return api.app.OpenInteractiveDialog(dialog)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
_, err := api.app.GetTeam(teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = api.app.RemoveTeamIcon(teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Plugin Section
|
||||
|
||||
func (api *PluginAPI) GetPlugins() ([]*model.Manifest, *model.AppError) {
|
||||
|
||||
@@ -87,18 +87,18 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := api.SavePluginConfig(pluginConfig); err != nil{
|
||||
if err := api.SavePluginConfig(pluginConfig); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
MyStringSetting string
|
||||
MyIntSetting int
|
||||
MyBoolSetting bool
|
||||
MyIntSetting int
|
||||
MyBoolSetting bool
|
||||
}
|
||||
|
||||
savedConfiguration := new(Configuration)
|
||||
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil{
|
||||
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -486,3 +486,26 @@ func TestPluginAPIGetChannelsForTeamForUser(t *testing.T) {
|
||||
assert.Empty(t, channels)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPluginAPIRemoveTeamIcon(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
// Create an 128 x 128 image
|
||||
img := image.NewRGBA(image.Rect(0, 0, 128, 128))
|
||||
|
||||
// Draw a red dot at (2, 3)
|
||||
img.Set(2, 3, color.RGBA{255, 0, 0, 255})
|
||||
buf := new(bytes.Buffer)
|
||||
err1 := png.Encode(buf, img)
|
||||
require.Nil(t, err1)
|
||||
dataBytes := buf.Bytes()
|
||||
fileReader := bytes.NewReader(dataBytes)
|
||||
|
||||
// Set the Team Icon
|
||||
err := th.App.SetTeamIconFromFile(th.BasicTeam, fileReader)
|
||||
require.Nil(t, err)
|
||||
err = api.RemoveTeamIcon(th.BasicTeam.Id)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user