summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanzei <16541325+hanzei@users.noreply.github.com>2018-10-15 19:18:23 +0200
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-10-15 19:18:23 +0200
commit71b7b9f090bc0f14c5737f4986fb6b5608fdd3ed (patch)
treec3a313e917f75c79a010a97e2887d0e50851808a
parenta35a9b9b2d9720a3753c96a4a3a36d437e518140 (diff)
downloadchat-71b7b9f090bc0f14c5737f4986fb6b5608fdd3ed.tar.gz
chat-71b7b9f090bc0f14c5737f4986fb6b5608fdd3ed.tar.bz2
chat-71b7b9f090bc0f14c5737f4986fb6b5608fdd3ed.zip
Add GetPostsBefore() to plugin API (#9651)
-rw-r--r--app/plugin_api.go4
-rw-r--r--plugin/api.go3
-rw-r--r--plugin/client_rpc_generated.go32
-rw-r--r--plugin/plugintest/api.go25
4 files changed, 64 insertions, 0 deletions
diff --git a/app/plugin_api.go b/app/plugin_api.go
index c57ca9eb5..4418c50c5 100644
--- a/app/plugin_api.go
+++ b/app/plugin_api.go
@@ -327,6 +327,10 @@ func (api *PluginAPI) GetPostsSince(channelId string, time int64) (*model.PostLi
return api.app.GetPostsSince(channelId, time)
}
+func (api *PluginAPI) GetPostsBefore(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError) {
+ return api.app.GetPostsBeforePost(channelId, postId, page, perPage)
+}
+
func (api *PluginAPI) GetPostsForChannel(channelId string, page, perPage int) (*model.PostList, *model.AppError) {
return api.app.GetPostsPage(channelId, page, perPage)
}
diff --git a/plugin/api.go b/plugin/api.go
index e0b3dde3c..713fab1b4 100644
--- a/plugin/api.go
+++ b/plugin/api.go
@@ -188,6 +188,9 @@ type API interface {
// GetPostsSince gets posts created after a specified time as Unix time in milliseconds.
GetPostsSince(channelId string, time int64) (*model.PostList, *model.AppError)
+ // GetPostsBefore gets a page of posts that were posted before the post provided.
+ GetPostsBefore(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError)
+
// GetPostsForChannel gets a list of posts for a channel.
GetPostsForChannel(channelId string, page, perPage int) (*model.PostList, *model.AppError)
diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go
index cf865f78c..890249014 100644
--- a/plugin/client_rpc_generated.go
+++ b/plugin/client_rpc_generated.go
@@ -2130,6 +2130,38 @@ func (s *apiRPCServer) GetPostsSince(args *Z_GetPostsSinceArgs, returns *Z_GetPo
return nil
}
+type Z_GetPostsBeforeArgs struct {
+ A string
+ B string
+ C int
+ D int
+}
+
+type Z_GetPostsBeforeReturns struct {
+ A *model.PostList
+ B *model.AppError
+}
+
+func (g *apiRPCClient) GetPostsBefore(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError) {
+ _args := &Z_GetPostsBeforeArgs{channelId, postId, page, perPage}
+ _returns := &Z_GetPostsBeforeReturns{}
+ if err := g.client.Call("Plugin.GetPostsBefore", _args, _returns); err != nil {
+ log.Printf("RPC call to GetPostsBefore API failed: %s", err.Error())
+ }
+ return _returns.A, _returns.B
+}
+
+func (s *apiRPCServer) GetPostsBefore(args *Z_GetPostsBeforeArgs, returns *Z_GetPostsBeforeReturns) error {
+ if hook, ok := s.impl.(interface {
+ GetPostsBefore(channelId, postId string, page, perPage int) (*model.PostList, *model.AppError)
+ }); ok {
+ returns.A, returns.B = hook.GetPostsBefore(args.A, args.B, args.C, args.D)
+ } else {
+ return encodableError(fmt.Errorf("API GetPostsBefore called but not implemented."))
+ }
+ return nil
+}
+
type Z_GetPostsForChannelArgs struct {
A string
B int
diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go
index a65b3a5d7..0e9402931 100644
--- a/plugin/plugintest/api.go
+++ b/plugin/plugintest/api.go
@@ -649,6 +649,31 @@ func (_m *API) GetPostThread(postId string) (*model.PostList, *model.AppError) {
return r0, r1
}
+// GetPostsBefore provides a mock function with given fields: channelId, postId, page, perPage
+func (_m *API) GetPostsBefore(channelId string, postId string, page int, perPage int) (*model.PostList, *model.AppError) {
+ ret := _m.Called(channelId, postId, page, perPage)
+
+ var r0 *model.PostList
+ if rf, ok := ret.Get(0).(func(string, string, int, int) *model.PostList); ok {
+ r0 = rf(channelId, postId, page, perPage)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(*model.PostList)
+ }
+ }
+
+ var r1 *model.AppError
+ if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
+ r1 = rf(channelId, postId, page, perPage)
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).(*model.AppError)
+ }
+ }
+
+ return r0, r1
+}
+
// GetPostsForChannel provides a mock function with given fields: channelId, page, perPage
func (_m *API) GetPostsForChannel(channelId string, page int, perPage int) (*model.PostList, *model.AppError) {
ret := _m.Called(channelId, page, perPage)