0
0
Fork 0

Change mentions of blocked users to not be processed (#19725)

Fixes #19698
This commit is contained in:
Claire 2022-11-04 13:19:12 +01:00 committed by GitHub
parent 20aa8881dc
commit 4fb0aae636
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 87 additions and 49 deletions

View file

@ -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