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?
|
||||
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
|
||||
|
||||
def account_present?
|
||||
|
@ -53,7 +59,15 @@ class StatusFilter
|
|||
!policy_allows_show?
|
||||
end
|
||||
|
||||
def blocked_by_policy_search?
|
||||
!policy_allows_search?
|
||||
end
|
||||
|
||||
def policy_allows_show?
|
||||
StatusPolicy.new(account, status, @preloaded_relations).show?
|
||||
end
|
||||
|
||||
def policy_allows_search?
|
||||
StatusPolicy.new(account, status, @preloaded_relations).search?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,10 @@ class StatusPolicy < ApplicationPolicy
|
|||
end
|
||||
end
|
||||
|
||||
def search?
|
||||
show? && (record.public_visibility? || record.public_unlisted_visibility?)
|
||||
end
|
||||
|
||||
def reblog?
|
||||
!requires_mention? && (!private? || owned?) && show? && !blocking_author?
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class SearchService < BaseService
|
|||
account_domains = results.map(&:account_domain)
|
||||
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
|
||||
[]
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue