diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-12-19 19:41:02 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-12-19 19:41:02 -0600 |
commit | 32d998b62333a768af3a274d265fd02483ce15de (patch) | |
tree | 8245f97e61ae116a9eb73512e7542ef703dedacc /app/models/status.rb | |
parent | 1fecec8fb6d1441078cf0cf36597007c53e81e6b (diff) |
add preference options to a: hide boosts globally, & b: show only packmates across all timelines - works in all client apps
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index d323b3d60..8f618ed31 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -125,6 +125,8 @@ class Status < ApplicationRecord scope :not_missing_media_desc, -> { left_outer_joins(:media_attachments).select('statuses.*').where('media_attachments.id IS NULL OR media_attachments.description IS NOT NULL') } + scope :only_followers_of, ->(account) { where(account: [account] + account.following) } + scope :tagged_with_all, ->(tags) { Array(tags).map(&:id).map(&:to_i).reduce(self) do |result, id| result.joins("INNER JOIN statuses_tags t#{id} ON t#{id}.status_id = statuses.id AND t#{id}.tag_id = #{id}") @@ -390,7 +392,9 @@ class Status < ApplicationRecord end def as_home_timeline(account) - where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private]) + query = where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private]) + query = query.without_reblogs if account.present? && account&.user&.hides_boosts? + query end def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false) @@ -440,13 +444,20 @@ class Status < ApplicationRecord else query = Status.curated end + query = query.without_replies unless Setting.show_replies_in_public_timelines + if account.present? && account.local? + query = query.without_reblogs if account&.user&.hides_boosts? + query = query.only_followers_of(account) if account&.user&.shows_only_known? + end + apply_timeline_filters(query, account, local_only) end def as_tag_timeline(tag, account = nil, local_only = false, priv = false) query = tag_timeline_scope(account, local_only, priv).tagged_with(tag) + query = query.only_followers_of(account) if account.present? && account.local? && account&.user&.shows_only_known? apply_timeline_filters(query, account, local_only, true) end |