Add filter to block sending some posts
This commit is contained in:
parent
401847d8cc
commit
4c08ce9d43
4 changed files with 26 additions and 6 deletions
|
@ -26,17 +26,20 @@ class AccountStatusesFilter
|
|||
scope.merge!(no_reblogs_scope) if exclude_reblogs?
|
||||
scope.merge!(hashtag_scope) if tagged?
|
||||
|
||||
scope.merge!(scope.where(searchability: :public)) if domain_block&.reject_send_not_public_searchability
|
||||
scope.merge!(scope.where.not(visibility: :unlisted)) if domain_block&.reject_send_unlisted_dissubscribable && @account.dissubscribable
|
||||
scope.merge!(scope.where.not(visibility: :public_unlisted)) if domain_block&.reject_send_public_unlisted
|
||||
scope.merge!(scope.where(spoiler_text: ['', nil])) if domain_block&.reject_send_sensitive
|
||||
|
||||
scope
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initial_scope
|
||||
if suspended?
|
||||
if suspended? || (domain_block&.reject_send_dissubscribable && @account.dissubscribable)
|
||||
Status.none
|
||||
elsif domain_block != nil && (domain_block&.reject_send_not_public_searchability || domain_block&.reject_send_unlisted_dissubscribable ||
|
||||
domain_block&.reject_send_public_unlisted || domain_block&.reject_send_media || domain_block&.reject_send_sensitive ||
|
||||
domain_block&.reject_send_sensitive)
|
||||
elsif domain_block&.reject_send_media
|
||||
Status.none
|
||||
elsif anonymous?
|
||||
account.statuses.where(visibility: %i(public unlisted public_unlisted))
|
||||
|
|
|
@ -49,7 +49,18 @@ class DomainBlock < ApplicationRecord
|
|||
if suspend?
|
||||
[:suspend]
|
||||
else
|
||||
[severity.to_sym, reject_media? ? :reject_media : nil, reject_favourite? ? :reject_favourite : nil, reject_reply? ? :reject_reply : nil, reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
[severity.to_sym,
|
||||
reject_media? ? :reject_media : nil,
|
||||
reject_favourite? ? :reject_favourite : nil,
|
||||
reject_reply? ? :reject_reply : nil,
|
||||
reject_send_not_public_searchability? ? :reject_send_not_public_searchability : nil,
|
||||
reject_send_unlisted_dissubscribable? ? :reject_send_unlisted_dissubscribable : nil,
|
||||
reject_send_public_unlisted? ? :reject_send_public_unlisted : nil,
|
||||
reject_send_dissubscribable? ? :reject_send_dissubscribable : nil,
|
||||
reject_send_media? ? :reject_send_media : nil,
|
||||
reject_send_sensitive? ? :reject_send_sensitive : nil,
|
||||
reject_reports? ? :reject_reports : nil
|
||||
].reject { |policy| policy == :noop || policy.nil? }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue