diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-11-04 13:19:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-04 13:19:12 +0100 |
commit | 4fb0aae636316e79b3c13c4000fda7765fa9474f (patch) | |
tree | 3a7dfb96f3ec2baf4a2476392bd736daccc6d1ec /app | |
parent | 20aa8881dc98264e5875fa37fc2dbf18e3f2baac (diff) |
Change mentions of blocked users to not be processed (#19725)
Fixes #19698
Diffstat (limited to 'app')
-rw-r--r-- | app/services/process_mentions_service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index c9c158af1..b117db8c2 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -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 |