From 0da0cf1a21d7dea61f4459ee71bf01b6ca362aee Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Mon, 9 Oct 2017 18:14:27 +0100 Subject: PLT-7826: Don't fetch posts from store if ES returns none. (#7596) --- app/post.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'app/post.go') diff --git a/app/post.go b/app/post.go index 497cab5a6..4a465450b 100644 --- a/app/post.go +++ b/app/post.go @@ -602,12 +602,14 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr // Get the posts postList := model.NewPostList() - if presult := <-a.Srv.Store.Post().GetPostsByIds(postIds); presult.Err != nil { - return nil, presult.Err - } else { - for _, p := range presult.Data.([]*model.Post) { - postList.AddPost(p) - postList.AddOrder(p.Id) + if len(postIds) > 0 { + if presult := <-a.Srv.Store.Post().GetPostsByIds(postIds); presult.Err != nil { + return nil, presult.Err + } else { + for _, p := range presult.Data.([]*model.Post) { + postList.AddPost(p) + postList.AddOrder(p.Id) + } } } -- cgit v1.2.3-1-g7c22 From 9adaf53e110e0e806b21903111aacb93129668cb Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 9 Oct 2017 13:30:48 -0400 Subject: PLT-7818 Updates to post type (#7579) * Updates to post type * Update tests --- app/post.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/post.go') diff --git a/app/post.go b/app/post.go index 4a465450b..fa929b844 100644 --- a/app/post.go +++ b/app/post.go @@ -29,6 +29,11 @@ func (a *App) CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) channel = result.Data.(*model.Channel) } + if strings.HasPrefix(post.Type, model.POST_SYSTEM_MESSAGE_PREFIX) { + err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.type"}, "", http.StatusBadRequest) + return nil, err + } + if channel.DeleteAt != 0 { err := model.NewAppError("createPost", "api.post.create_post.can_not_post_to_deleted.error", nil, "", http.StatusBadRequest) return nil, err -- cgit v1.2.3-1-g7c22