diff --git a/app/models/public_feed.rb b/app/models/public_feed.rb index 8a7c3a4512aebd..9358980d181f5e 100644 --- a/app/models/public_feed.rb +++ b/app/models/public_feed.rb @@ -25,6 +25,7 @@ def get(limit, max_id = nil, since_id = nil, min_id = nil) scope.merge!(without_local_only_scope) unless allow_local_only? scope.merge!(without_replies_scope) unless with_replies? scope.merge!(without_reblogs_scope) unless with_reblogs? + scope.merge!(without_duplicate_reblogs) if with_reblogs? scope.merge!(local_only_scope) if local_only? scope.merge!(remote_only_scope) if remote_only? scope.merge!(account_filters_scope) if account? @@ -90,6 +91,11 @@ def without_reblogs_scope Status.without_reblogs end + def without_duplicate_reblogs + Status.where(statuses: { reblog_of_id: nil }) + .or(Status.where(id: Status.select('DISTINCT ON (reblog_of_id) statuses.id').reorder(reblog_of_id: :desc, id: :desc))) + end + def media_only_scope Status.joins(:media_attachments).group(:id) end