Move Thread.GetPosts to PostStore.GetPostsByThread (#21633)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ab5137395c
Коммит
98e685f07c
@@ -1400,6 +1400,23 @@ func (s *SqlPostStore) GetPostsAfter(options model.GetPostsOptions, sanitizeOpti
|
||||
return s.getPostsAround(false, options, sanitizeOptions)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsByThread(threadId string, since int64) ([]*model.Post, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("*").
|
||||
From("Posts").
|
||||
Where(sq.Eq{"RootId": threadId}).
|
||||
Where(sq.Eq{"DeleteAt": 0}).
|
||||
Where(sq.GtOrEq{"CreateAt": since})
|
||||
|
||||
result := []*model.Post{}
|
||||
err := s.GetReplicaX().SelectBuilder(&result, query)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to fetch thread posts")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
if options.Page < 0 {
|
||||
return nil, store.NewErrInvalidInput("Post", "<options.Page>", options.Page)
|
||||
|
||||
@@ -779,23 +779,6 @@ func (s *SqlThreadStore) MaintainMembership(userId, postId string, opts store.Th
|
||||
return membership, err
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) GetPosts(threadId string, since int64) ([]*model.Post, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("*").
|
||||
From("Posts").
|
||||
Where(sq.Eq{"RootId": threadId}).
|
||||
Where(sq.Eq{"DeleteAt": 0}).
|
||||
Where(sq.GtOrEq{"CreateAt": since})
|
||||
|
||||
result := []*model.Post{}
|
||||
err := s.GetReplicaX().SelectBuilder(&result, query)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to fetch thread posts")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PermanentDeleteBatchForRetentionPolicies deletes a batch of records which are affected by
|
||||
// the global or a granular retention policy.
|
||||
// See `genericPermanentDeleteBatchForRetentionPolicies` for details.
|
||||
|
||||
Ссылка в новой задаче
Block a user