From 5c329014a1c2fdbf34c23d4da994bd96e92b5e81 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 18 Aug 2020 00:52:17 -0500 Subject: [Privacy] Allow forcing local-only posts to be excluded in apply_account_filters and include account filters in own posts --- app/models/status.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/status.rb b/app/models/status.rb index 62f8d2778..68093eb73 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -524,7 +524,6 @@ class Status < ApplicationRecord visibility = :public if options[:public] || (account.blank? && !target_account.show_unlisted?) scope = where(visibility: visibility) - scope = apply_account_filters(scope, account, **options) apply_category_filters(scope, target_account, account, **options) end @@ -554,6 +553,8 @@ class Status < ApplicationRecord # TODO: Cast cleanup spell. # rubocop:disable Metrics/PerceivedComplexity def apply_category_filters(query, target_account, account, **options) + options[:without_account_filters] ||= target_account.id == account&.id + query = apply_account_filters(query, account, **options) return query if options[:without_category_filters] query = query.published unless options[:include_unpublished] @@ -602,9 +603,9 @@ class Status < ApplicationRecord def apply_account_filters(query, account, **options) return query.not_local_only if account.blank? - return (account.local? ? query : query.not_local_only) if options[:without_account_filters] + return (!options[:exclude_local_only] && account.local? ? query : query.not_local_only) if options[:without_account_filters] - query = query.not_local_only unless account.local? + query = query.not_local_only unless !options[:exclude_local_only] && account.local? query = query.not_hidden_by_account(account) query = query.in_chosen_languages(account) if account.chosen_languages.present? query -- cgit