From c3d536c644f102cbdc07354aa2ecf8bc8194882e Mon Sep 17 00:00:00 2001 From: S4KH Date: Fri, 19 Oct 2018 04:07:21 +0800 Subject: GH-9619 GetEmojiImage added to plugin API (#9628) * GH-9619 conflict fix * GH-9619 fixed conflicts, version comment --- app/plugin_api.go | 4 ++++ plugin/api.go | 5 +++++ plugin/client_rpc_generated.go | 30 ++++++++++++++++++++++++++++++ plugin/plugintest/api.go | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) diff --git a/app/plugin_api.go b/app/plugin_api.go index 244f0bd7a..48f07275e 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -398,6 +398,10 @@ func (api *PluginAPI) ReadFile(path string) ([]byte, *model.AppError) { return api.app.ReadFile(path) } +func (api *PluginAPI) GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) { + return api.app.GetEmojiImage(emojiId) +} + func (api *PluginAPI) KVSet(key string, value []byte) *model.AppError { return api.app.SetPluginKey(api.id, key, value) } diff --git a/plugin/api.go b/plugin/api.go index fc64c627a..dc60bb57a 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -276,6 +276,11 @@ type API interface { // Minimum server version: 5.3 ReadFile(path string) ([]byte, *model.AppError) + // GetEmojiImage returns the emoji image. + // + // Minimum server version: 5.6 + GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) + // KVSet will store a key-value pair, unique per plugin. KVSet(key string, value []byte) *model.AppError diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index db4acaec1..d99b7b0e6 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -2518,6 +2518,36 @@ func (s *apiRPCServer) ReadFile(args *Z_ReadFileArgs, returns *Z_ReadFileReturns return nil } +type Z_GetEmojiImageArgs struct { + A string +} + +type Z_GetEmojiImageReturns struct { + A []byte + B string + C *model.AppError +} + +func (g *apiRPCClient) GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) { + _args := &Z_GetEmojiImageArgs{emojiId} + _returns := &Z_GetEmojiImageReturns{} + if err := g.client.Call("Plugin.GetEmojiImage", _args, _returns); err != nil { + log.Printf("RPC call to GetEmojiImage API failed: %s", err.Error()) + } + return _returns.A, _returns.B, _returns.C +} + +func (s *apiRPCServer) GetEmojiImage(args *Z_GetEmojiImageArgs, returns *Z_GetEmojiImageReturns) error { + if hook, ok := s.impl.(interface { + GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) + }); ok { + returns.A, returns.B, returns.C = hook.GetEmojiImage(args.A) + } else { + return encodableError(fmt.Errorf("API GetEmojiImage called but not implemented.")) + } + return nil +} + type Z_KVSetArgs struct { A string B []byte diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index 00328d155..b3df3616f 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -549,6 +549,38 @@ func (_m *API) GetEmojiByName(name string) (*model.Emoji, *model.AppError) { return r0, r1 } +// GetEmojiImage provides a mock function with given fields: emojiId +func (_m *API) GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) { + ret := _m.Called(emojiId) + + var r0 []byte + if rf, ok := ret.Get(0).(func(string) []byte); ok { + r0 = rf(emojiId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + var r1 string + if rf, ok := ret.Get(1).(func(string) string); ok { + r1 = rf(emojiId) + } else { + r1 = ret.Get(1).(string) + } + + var r2 *model.AppError + if rf, ok := ret.Get(2).(func(string) *model.AppError); ok { + r2 = rf(emojiId) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).(*model.AppError) + } + } + + return r0, r1, r2 +} + // GetFileInfo provides a mock function with given fields: fileId func (_m *API) GetFileInfo(fileId string) (*model.FileInfo, *model.AppError) { ret := _m.Called(fileId) -- cgit v1.2.3-1-g7c22