Except for unlisted from search results
This commit is contained in:
parent
08e5d96a4a
commit
5e8bdaaab6
3 changed files with 19 additions and 1 deletions
|
@ -15,6 +15,12 @@ class StatusFilter
|
||||||
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_filtered?
|
||||||
|
return false if !account.nil? && account.id == status.account_id
|
||||||
|
|
||||||
|
blocked_by_policy_search? || (account_present? && filtered_status?) || silenced_account?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def account_present?
|
def account_present?
|
||||||
|
@ -53,7 +59,15 @@ class StatusFilter
|
||||||
!policy_allows_show?
|
!policy_allows_show?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blocked_by_policy_search?
|
||||||
|
!policy_allows_search?
|
||||||
|
end
|
||||||
|
|
||||||
def policy_allows_show?
|
def policy_allows_show?
|
||||||
StatusPolicy.new(account, status, @preloaded_relations).show?
|
StatusPolicy.new(account, status, @preloaded_relations).show?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def policy_allows_search?
|
||||||
|
StatusPolicy.new(account, status, @preloaded_relations).search?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,10 @@ class StatusPolicy < ApplicationPolicy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search?
|
||||||
|
show? && (record.public_visibility? || record.public_unlisted_visibility?)
|
||||||
|
end
|
||||||
|
|
||||||
def reblog?
|
def reblog?
|
||||||
!requires_mention? && (!private? || owned?) && show? && !blocking_author?
|
!requires_mention? && (!private? || owned?) && show? && !blocking_author?
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SearchService < BaseService
|
||||||
account_domains = results.map(&:account_domain)
|
account_domains = results.map(&:account_domain)
|
||||||
preloaded_relations = relations_map_for_account(@account, account_ids, account_domains)
|
preloaded_relations = relations_map_for_account(@account, account_ids, account_domains)
|
||||||
|
|
||||||
results.reject { |status| StatusFilter.new(status, @account, preloaded_relations).filtered? }
|
results.reject { |status| StatusFilter.new(status, @account, preloaded_relations).search_filtered? }
|
||||||
rescue Faraday::ConnectionFailed, Parslet::ParseFailed
|
rescue Faraday::ConnectionFailed, Parslet::ParseFailed
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue