MM-16872 - Extend Plugin API to set LHS bot icon (#11601)
* MM-16872 - Extend Plugin API to set LHS bot icon * MM-16872 - Using ReadSeeker as opposed to Reader for reading svg image file * MM-16872 - PR feedback * MM-16872 - Using userId rather than bot.UserId * MM-16872 - Minor stylistic changes * MM-16872 - Removing DriverName check
Этот коммит содержится в:
@@ -569,6 +569,22 @@ type API interface {
|
||||
//
|
||||
// Minimum server version: 5.10
|
||||
PermanentDeleteBot(botUserId string) *model.AppError
|
||||
|
||||
// GetBotIconImage gets LHS bot icon image.
|
||||
//
|
||||
// Minimum server version: 5.14
|
||||
GetBotIconImage(botUserId string) ([]byte, *model.AppError)
|
||||
|
||||
// SetBotIconImage sets LHS bot icon image.
|
||||
// Icon image must be SVG format, all other formats are rejected.
|
||||
//
|
||||
// Minimum server version: 5.14
|
||||
SetBotIconImage(botUserId string, data []byte) *model.AppError
|
||||
|
||||
// DeleteBotIconImage deletes LHS bot icon image.
|
||||
//
|
||||
// Minimum server version: 5.14
|
||||
DeleteBotIconImage(botUserId string) *model.AppError
|
||||
}
|
||||
|
||||
var handshake = plugin.HandshakeConfig{
|
||||
|
||||
@@ -4100,3 +4100,89 @@ func (s *apiRPCServer) PermanentDeleteBot(args *Z_PermanentDeleteBotArgs, return
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetBotIconImageArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_GetBotIconImageReturns struct {
|
||||
A []byte
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetBotIconImage(botUserId string) ([]byte, *model.AppError) {
|
||||
_args := &Z_GetBotIconImageArgs{botUserId}
|
||||
_returns := &Z_GetBotIconImageReturns{}
|
||||
if err := g.client.Call("Plugin.GetBotIconImage", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetBotIconImage API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetBotIconImage(args *Z_GetBotIconImageArgs, returns *Z_GetBotIconImageReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetBotIconImage(botUserId string) ([]byte, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetBotIconImage(args.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetBotIconImage called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_SetBotIconImageArgs struct {
|
||||
A string
|
||||
B []byte
|
||||
}
|
||||
|
||||
type Z_SetBotIconImageReturns struct {
|
||||
A *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) SetBotIconImage(botUserId string, data []byte) *model.AppError {
|
||||
_args := &Z_SetBotIconImageArgs{botUserId, data}
|
||||
_returns := &Z_SetBotIconImageReturns{}
|
||||
if err := g.client.Call("Plugin.SetBotIconImage", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to SetBotIconImage API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) SetBotIconImage(args *Z_SetBotIconImageArgs, returns *Z_SetBotIconImageReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
SetBotIconImage(botUserId string, data []byte) *model.AppError
|
||||
}); ok {
|
||||
returns.A = hook.SetBotIconImage(args.A, args.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API SetBotIconImage called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeleteBotIconImageArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_DeleteBotIconImageReturns struct {
|
||||
A *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) DeleteBotIconImage(botUserId string) *model.AppError {
|
||||
_args := &Z_DeleteBotIconImageArgs{botUserId}
|
||||
_returns := &Z_DeleteBotIconImageReturns{}
|
||||
if err := g.client.Call("Plugin.DeleteBotIconImage", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to DeleteBotIconImage API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) DeleteBotIconImage(args *Z_DeleteBotIconImageArgs, returns *Z_DeleteBotIconImageReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
DeleteBotIconImage(botUserId string) *model.AppError
|
||||
}); ok {
|
||||
returns.A = hook.DeleteBotIconImage(args.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API DeleteBotIconImage called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -262,6 +262,22 @@ func (_m *API) CreateUser(user *model.User) (*model.User, *model.AppError) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DeleteBotIconImage provides a mock function with given fields: botUserId
|
||||
func (_m *API) DeleteBotIconImage(botUserId string) *model.AppError {
|
||||
ret := _m.Called(botUserId)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||
r0 = rf(botUserId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteChannel provides a mock function with given fields: channelId
|
||||
func (_m *API) DeleteChannel(channelId string) *model.AppError {
|
||||
ret := _m.Called(channelId)
|
||||
@@ -420,6 +436,31 @@ func (_m *API) GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetBotIconImage provides a mock function with given fields: botUserId
|
||||
func (_m *API) GetBotIconImage(botUserId string) ([]byte, *model.AppError) {
|
||||
ret := _m.Called(botUserId)
|
||||
|
||||
var r0 []byte
|
||||
if rf, ok := ret.Get(0).(func(string) []byte); ok {
|
||||
r0 = rf(botUserId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
r1 = rf(botUserId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetBots provides a mock function with given fields: options
|
||||
func (_m *API) GetBots(options *model.BotGetOptions) ([]*model.Bot, *model.AppError) {
|
||||
ret := _m.Called(options)
|
||||
@@ -2358,6 +2399,22 @@ func (_m *API) SendMail(to string, subject string, htmlBody string) *model.AppEr
|
||||
return r0
|
||||
}
|
||||
|
||||
// SetBotIconImage provides a mock function with given fields: botUserId, data
|
||||
func (_m *API) SetBotIconImage(botUserId string, data []byte) *model.AppError {
|
||||
ret := _m.Called(botUserId, data)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, []byte) *model.AppError); ok {
|
||||
r0 = rf(botUserId, data)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// SetProfileImage provides a mock function with given fields: userId, data
|
||||
func (_m *API) SetProfileImage(userId string, data []byte) *model.AppError {
|
||||
ret := _m.Called(userId, data)
|
||||
|
||||
Ссылка в новой задаче
Block a user