summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorGabin Aureche <gabin.aureche@live.fr>2017-03-13 13:25:08 +0100
committerGeorge Goldberg <george@gberg.me>2017-03-13 12:25:08 +0000
commitfe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81 (patch)
treeb96d457cde64b7397f91028106e93a7f92a179bd /store/sql_channel_store.go
parent482a0fb5fc248b1ec61db35299dc3e6d963ad5ab (diff)
downloadchat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.gz
chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.bz2
chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.zip
Add pinned posts (#4217)
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index ff1716957..27a00f484 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -321,6 +321,32 @@ func (s SqlChannelStore) Get(id string, allowFromCache bool) StoreChannel {
return s.get(id, false, allowFromCache)
}
+func (s SqlChannelStore) GetPinnedPosts(channelId string) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+ pl := &model.PostList{}
+
+ var posts []*model.Post
+ if _, err := s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE IsPinned = true AND ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt ASC", map[string]interface{}{"ChannelId": channelId}); err != nil {
+ result.Err = model.NewLocAppError("SqlPostStore.GetPinnedPosts", "store.sql_channel.pinned_posts.app_error", nil, err.Error())
+ } else {
+ for _, post := range posts {
+ pl.AddPost(post)
+ pl.AddOrder(post.Id)
+ }
+ }
+
+ result.Data = pl
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (s SqlChannelStore) GetFromMaster(id string) StoreChannel {
return s.get(id, true, false)
}