Change mentions of blocked users to not be processed (#19725)
Fixes #19698
This commit is contained in:
parent
20aa8881dc
commit
4fb0aae636
2 changed files with 87 additions and 49 deletions
|
@ -66,6 +66,16 @@ class ProcessMentionsService < BaseService
|
|||
end
|
||||
|
||||
def assign_mentions!
|
||||
# Make sure we never mention blocked accounts
|
||||
unless @current_mentions.empty?
|
||||
mentioned_domains = @current_mentions.map { |m| m.account.domain }.compact.uniq
|
||||
blocked_domains = Set.new(mentioned_domains.empty? ? [] : AccountDomainBlock.where(account_id: @status.account_id, domain: mentioned_domains))
|
||||
mentioned_account_ids = @current_mentions.map(&:account_id)
|
||||
blocked_account_ids = Set.new(@status.account.block_relationships.where(target_account_id: mentioned_account_ids).pluck(:target_account_id))
|
||||
|
||||
@current_mentions.select! { |mention| !(blocked_account_ids.include?(mention.account_id) || blocked_domains.include?(mention.account.domain)) }
|
||||
end
|
||||
|
||||
@current_mentions.each do |mention|
|
||||
mention.save if mention.new_record?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue