Skip to content

Commit

Permalink
Prevent duplicate boosts from appearing in local feed - only show mos…
Browse files Browse the repository at this point in the history
…t recent boost
  • Loading branch information
sneakers-the-rat committed Jan 25, 2024
1 parent eb354f3 commit 7c465c3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/public_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7c465c3

Please sign in to comment.