From a9ee2e01c5584396000b0368fe8366d60ab29534 Mon Sep 17 00:00:00 2001 From: Jason Mojica Date: Thu, 25 Oct 2018 13:54:10 +0000 Subject: GH-9617 Add plugin API for GetEmoji method (#9656) * Add GetEmoji plugin api * Add server version --- app/plugin_api.go | 4 ++++ plugin/api.go | 5 +++++ plugin/client_rpc_generated.go | 29 +++++++++++++++++++++++++++++ plugin/plugintest/api.go | 25 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/app/plugin_api.go b/app/plugin_api.go index 3bb638a24..c409a88f8 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -377,6 +377,10 @@ func (api *PluginAPI) GetEmojiByName(name string) (*model.Emoji, *model.AppError return api.app.GetEmojiByName(name) } +func (api *PluginAPI) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) { + return api.app.GetEmoji(emojiId) +} + func (api *PluginAPI) CopyFileInfos(userId string, fileIds []string) ([]string, *model.AppError) { return api.app.CopyFileInfos(userId, fileIds) } diff --git a/plugin/api.go b/plugin/api.go index 0f481784e..93b5a6d2e 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -254,6 +254,11 @@ type API interface { // Minimum server version: 5.6 GetEmojiByName(name string) (*model.Emoji, *model.AppError) + // GetEmoji returns a custom emoji based on the emojiId string. + // + // Minimum server version: 5.6 + GetEmoji(emojiId string) (*model.Emoji, *model.AppError) + // CopyFileInfos duplicates the FileInfo objects referenced by the given file ids, // recording the given user id as the new creator and returning the new set of file ids. // diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index 7ed016c24..b3886dcb3 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -2402,6 +2402,35 @@ func (s *apiRPCServer) GetEmojiByName(args *Z_GetEmojiByNameArgs, returns *Z_Get return nil } +type Z_GetEmojiArgs struct { + A string +} + +type Z_GetEmojiReturns struct { + A *model.Emoji + B *model.AppError +} + +func (g *apiRPCClient) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) { + _args := &Z_GetEmojiArgs{emojiId} + _returns := &Z_GetEmojiReturns{} + if err := g.client.Call("Plugin.GetEmoji", _args, _returns); err != nil { + log.Printf("RPC call to GetEmoji API failed: %s", err.Error()) + } + return _returns.A, _returns.B +} + +func (s *apiRPCServer) GetEmoji(args *Z_GetEmojiArgs, returns *Z_GetEmojiReturns) error { + if hook, ok := s.impl.(interface { + GetEmoji(emojiId string) (*model.Emoji, *model.AppError) + }); ok { + returns.A, returns.B = hook.GetEmoji(args.A) + } else { + return encodableError(fmt.Errorf("API GetEmoji called but not implemented.")) + } + return nil +} + type Z_CopyFileInfosArgs struct { A string B []string diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index 4e94e17af..81462e58d 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -581,6 +581,31 @@ func (_m *API) GetEmojiImage(emojiId string) ([]byte, string, *model.AppError) { return r0, r1, r2 } +// GetEmoji provides a mock function with given fields: emojiId +func (_m *API) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) { + ret := _m.Called(emojiId) + + var r0 *model.Emoji + if rf, ok := ret.Get(0).(func(string) *model.Emoji); ok { + r0 = rf(emojiId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.Emoji) + } + } + + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { + r1 = rf(emojiId) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) + } + } + + return r0, r1 +} + // 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