Add pinned posts (#4217)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
482a0fb5fc
Коммит
fe38d6d5bb
@@ -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)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user