diff options
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index b2211a180..834e488a8 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -1287,3 +1287,30 @@ func (s SqlPostStore) GetPostsCreatedAt(channelId string, time int64) StoreChann return storeChannel } + +func (s SqlPostStore) GetPostsByIds(postIds []string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + inClause := `'` + strings.Join(postIds, `', '`) + `'` + + query := `SELECT * FROM Posts WHERE Id in (` + inClause + `) and DeleteAt = 0 ORDER BY CreateAt DESC` + + var posts []*model.Post + _, err := s.GetReplica().Select(&posts, query, map[string]interface{}{}) + + if err != nil { + l4g.Error(err) + result.Err = model.NewAppError("SqlPostStore.GetPostsCreatedAt", "store.sql_post.get_posts_by_ids.app_error", nil, "", http.StatusInternalServerError) + } else { + result.Data = posts + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} |