Add RemoveTeamIcon plugin api (#9847)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c46d8ec892
Коммит
2555a5d45d
@@ -510,6 +510,19 @@ func (api *PluginAPI) OpenInteractiveDialog(dialog model.OpenDialogRequest) *mod
|
|||||||
return api.app.OpenInteractiveDialog(dialog)
|
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
|
// Plugin Section
|
||||||
|
|
||||||
func (api *PluginAPI) GetPlugins() ([]*model.Manifest, *model.AppError) {
|
func (api *PluginAPI) GetPlugins() ([]*model.Manifest, *model.AppError) {
|
||||||
|
|||||||
@@ -87,18 +87,18 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := api.SavePluginConfig(pluginConfig); err != nil{
|
if err := api.SavePluginConfig(pluginConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
MyStringSetting string
|
MyStringSetting string
|
||||||
MyIntSetting int
|
MyIntSetting int
|
||||||
MyBoolSetting bool
|
MyBoolSetting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
savedConfiguration := new(Configuration)
|
savedConfiguration := new(Configuration)
|
||||||
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil{
|
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,3 +486,26 @@ func TestPluginAPIGetChannelsForTeamForUser(t *testing.T) {
|
|||||||
assert.Empty(t, channels)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,16 +74,21 @@ type API interface {
|
|||||||
// Minimum server version: 5.6
|
// Minimum server version: 5.6
|
||||||
GetUsersInTeam(teamId string, page int, perPage int) ([]*model.User, *model.AppError)
|
GetUsersInTeam(teamId string, page int, perPage int) ([]*model.User, *model.AppError)
|
||||||
|
|
||||||
// GetTeamIcon gets the Team Icon.
|
// GetTeamIcon gets the team icon.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.6
|
// Minimum server version: 5.6
|
||||||
GetTeamIcon(teamId string) ([]byte, *model.AppError)
|
GetTeamIcon(teamId string) ([]byte, *model.AppError)
|
||||||
|
|
||||||
// SetTeamIcon sets the Team Icon.
|
// SetTeamIcon sets the team icon.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.6
|
// Minimum server version: 5.6
|
||||||
SetTeamIcon(teamId string, data []byte) *model.AppError
|
SetTeamIcon(teamId string, data []byte) *model.AppError
|
||||||
|
|
||||||
|
// RemoveTeamIcon removes the team icon.
|
||||||
|
//
|
||||||
|
// Minimum server version: 5.6
|
||||||
|
RemoveTeamIcon(teamId string) *model.AppError
|
||||||
|
|
||||||
// UpdateUser updates a user.
|
// UpdateUser updates a user.
|
||||||
UpdateUser(user *model.User) (*model.User, *model.AppError)
|
UpdateUser(user *model.User) (*model.User, *model.AppError)
|
||||||
|
|
||||||
|
|||||||
@@ -1000,6 +1000,34 @@ func (s *apiRPCServer) SetTeamIcon(args *Z_SetTeamIconArgs, returns *Z_SetTeamIc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Z_RemoveTeamIconArgs struct {
|
||||||
|
A string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Z_RemoveTeamIconReturns struct {
|
||||||
|
A *model.AppError
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *apiRPCClient) RemoveTeamIcon(teamId string) *model.AppError {
|
||||||
|
_args := &Z_RemoveTeamIconArgs{teamId}
|
||||||
|
_returns := &Z_RemoveTeamIconReturns{}
|
||||||
|
if err := g.client.Call("Plugin.RemoveTeamIcon", _args, _returns); err != nil {
|
||||||
|
log.Printf("RPC call to RemoveTeamIcon API failed: %s", err.Error())
|
||||||
|
}
|
||||||
|
return _returns.A
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *apiRPCServer) RemoveTeamIcon(args *Z_RemoveTeamIconArgs, returns *Z_RemoveTeamIconReturns) error {
|
||||||
|
if hook, ok := s.impl.(interface {
|
||||||
|
RemoveTeamIcon(teamId string) *model.AppError
|
||||||
|
}); ok {
|
||||||
|
returns.A = hook.RemoveTeamIcon(args.A)
|
||||||
|
} else {
|
||||||
|
return encodableError(fmt.Errorf("API RemoveTeamIcon called but not implemented."))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type Z_UpdateUserArgs struct {
|
type Z_UpdateUserArgs struct {
|
||||||
A *model.User
|
A *model.User
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1833,6 +1833,22 @@ func (_m *API) RemoveReaction(reaction *model.Reaction) *model.AppError {
|
|||||||
return r0
|
return r0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveTeamIcon provides a mock function with given fields: teamId
|
||||||
|
func (_m *API) RemoveTeamIcon(teamId string) *model.AppError {
|
||||||
|
ret := _m.Called(teamId)
|
||||||
|
|
||||||
|
var r0 *model.AppError
|
||||||
|
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||||
|
r0 = rf(teamId)
|
||||||
|
} else {
|
||||||
|
if ret.Get(0) != nil {
|
||||||
|
r0 = ret.Get(0).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
// SaveConfig provides a mock function with given fields: config
|
// SaveConfig provides a mock function with given fields: config
|
||||||
func (_m *API) SaveConfig(config *model.Config) *model.AppError {
|
func (_m *API) SaveConfig(config *model.Config) *model.AppError {
|
||||||
ret := _m.Called(config)
|
ret := _m.Called(config)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user