From 1cdf717446d79191701949a97557f801681bc278 Mon Sep 17 00:00:00 2001 From: Charles Kenney Date: Mon, 15 Oct 2018 17:09:30 -0400 Subject: add GetEmojiByName method to plugin API (#9641) --- app/plugin_api.go | 4 ++++ plugin/api.go | 3 +++ plugin/client_rpc_generated.go | 29 +++++++++++++++++++++++++++++ plugin/plugintest/api.go | 25 +++++++++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/app/plugin_api.go b/app/plugin_api.go index 4418c50c5..9afc5bb73 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -349,6 +349,10 @@ func (api *PluginAPI) GetProfileImage(userId string) ([]byte, *model.AppError) { return data, err } +func (api *PluginAPI) GetEmojiByName(name string) (*model.Emoji, *model.AppError) { + return api.app.GetEmojiByName(name) +} + 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 713fab1b4..a4d643187 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -200,6 +200,9 @@ type API interface { // GetProfileImage gets user's profile image GetProfileImage(userId string) ([]byte, *model.AppError) + // GetEmojiByName gets an emoji by it's name. + GetEmojiByName(name 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 890249014..b53f10aff 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -2251,6 +2251,35 @@ func (s *apiRPCServer) GetProfileImage(args *Z_GetProfileImageArgs, returns *Z_G return nil } +type Z_GetEmojiByNameArgs struct { + A string +} + +type Z_GetEmojiByNameReturns struct { + A *model.Emoji + B *model.AppError +} + +func (g *apiRPCClient) GetEmojiByName(name string) (*model.Emoji, *model.AppError) { + _args := &Z_GetEmojiByNameArgs{name} + _returns := &Z_GetEmojiByNameReturns{} + if err := g.client.Call("Plugin.GetEmojiByName", _args, _returns); err != nil { + log.Printf("RPC call to GetEmojiByName API failed: %s", err.Error()) + } + return _returns.A, _returns.B +} + +func (s *apiRPCServer) GetEmojiByName(args *Z_GetEmojiByNameArgs, returns *Z_GetEmojiByNameReturns) error { + if hook, ok := s.impl.(interface { + GetEmojiByName(name string) (*model.Emoji, *model.AppError) + }); ok { + returns.A, returns.B = hook.GetEmojiByName(args.A) + } else { + return encodableError(fmt.Errorf("API GetEmojiByName 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 0e9402931..d17c9dc5c 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -524,6 +524,31 @@ func (_m *API) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, return r0, r1 } +// GetEmojiByName provides a mock function with given fields: name +func (_m *API) GetEmojiByName(name string) (*model.Emoji, *model.AppError) { + ret := _m.Called(name) + + var r0 *model.Emoji + if rf, ok := ret.Get(0).(func(string) *model.Emoji); ok { + r0 = rf(name) + } 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(name) + } 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