* Add full-text search for authorized statuses - Search API will return statuses that match the query - Only for logged in users - Only if you are author of the status, - Or you were mentioned in it - Or you favourited or reblogged it - Configuration over `ES_ENABLED`, `ES_HOST`, `ES_PORT`, `ES_PREFIX` - Run `rails chewy:deploy` to create & populate index Fix #5880 Fix #4293 Fix #1152 * Add commented out docker-compose configuration for ES container * Optimize index import, filter search results * Add basic normalization to the index * Add better stemming and normalization to the index * Skip webfinger request if search query includes both @ and a space * Fix code style * Visually separate search result sections * Fix code style issues
57 lines
1.1 KiB
Ruby
57 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class StatusFilter
|
|
attr_reader :status, :account
|
|
|
|
def initialize(status, account)
|
|
@status = status
|
|
@account = account
|
|
end
|
|
|
|
def filtered?
|
|
return false if !account.nil? && account.id == status.account_id
|
|
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
|
end
|
|
|
|
private
|
|
|
|
def account_present?
|
|
!account.nil?
|
|
end
|
|
|
|
def filtered_status?
|
|
blocking_account? || blocking_domain? || muting_account?
|
|
end
|
|
|
|
def blocking_account?
|
|
account.blocking? status.account_id
|
|
end
|
|
|
|
def blocking_domain?
|
|
account.domain_blocking? status.account_domain
|
|
end
|
|
|
|
def muting_account?
|
|
account.muting? status.account_id
|
|
end
|
|
|
|
def silenced_account?
|
|
!account&.silenced? && status_account_silenced? && !account_following_status_account?
|
|
end
|
|
|
|
def status_account_silenced?
|
|
status.account.silenced?
|
|
end
|
|
|
|
def account_following_status_account?
|
|
account&.following? status.account_id
|
|
end
|
|
|
|
def blocked_by_policy?
|
|
!policy_allows_show?
|
|
end
|
|
|
|
def policy_allows_show?
|
|
StatusPolicy.new(account, status).show?
|
|
end
|
|
end
|