From 8efbea953c436af514f6b39eb22316100e522c90 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sat, 15 Aug 2020 02:12:04 -0500 Subject: [Federation] Force out-of-body mentions to be delivered without a notification --- app/services/process_mentions_service.rb | 3 +-- app/services/resolve_mentions_service.rb | 20 ++------------------ 2 files changed, 3 insertions(+), 20 deletions(-) (limited to 'app/services') diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index fea00ef4f..2ec21f22b 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -8,13 +8,12 @@ class ProcessMentionsService < BaseService # remote users # @param [Status] status # @option [Enumerable] :mentions Mentions to include - # @option [Boolean] :reveal_implicit_mentions Append implicit mentions to text # @option [Boolean] :deliver Deliver mention notifications def call(status, mentions: [], reveal_implicit_mentions: true, deliver: true) return unless status.local? @status = status - @status.text, mentions = ResolveMentionsService.new.call(@status, mentions: mentions, reveal_implicit_mentions: reveal_implicit_mentions) + @status.text, mentions = ResolveMentionsService.new.call(@status, mentions: mentions) @status.save! return unless deliver diff --git a/app/services/resolve_mentions_service.rb b/app/services/resolve_mentions_service.rb index 2fcb176b2..e51e9f1ef 100644 --- a/app/services/resolve_mentions_service.rb +++ b/app/services/resolve_mentions_service.rb @@ -5,9 +5,8 @@ class ResolveMentionsService < BaseService # @param [Status] status Status to attach to mention pointers # @option [String] :text Text containing mentions to resolve (default: use status text) # @option [Enumerable] :mentions Additional mentions to include - # @option [Boolean] :reveal_implicit_mentions Append implicit mentions to text # @return [Array] Array containing text with mentions resolved (String) and mention pointers (Set) - def call(status, text: nil, mentions: [], reveal_implicit_mentions: true) + def call(status, text: nil, mentions: []) mentions = Mention.includes(:account).where(id: mentions.pluck(:id), accounts: { suspended_at: nil }).or(status.mentions.includes(:account)) implicit_mention_acct_ids = mentions.active.pluck(:account_id).to_set text = status.text if text.nil? @@ -45,12 +44,7 @@ class ResolveMentionsService < BaseService "@#{mentioned_account.acct}" end - if reveal_implicit_mentions && implicit_mention_acct_ids.present? - implicit_mention_accts = Account.where(id: implicit_mention_acct_ids, suspended_at: nil) - formatted_accts = format_mentions(implicit_mention_accts) - formatted_accts = Formatter.instance.linkify(formatted_accts, implicit_mention_accts) unless status.local? - text << formatted_accts - end + Mention.where(id: implicit_mention_acct_ids).update_all(silent: true) [text, mentions] end @@ -64,14 +58,4 @@ class ResolveMentionsService < BaseService def resolve_account_service ResolveAccountService.new end - - def format_mentions(accounts) - "\n\n#{accounts_to_mentions(accounts).join(' ')}" - end - - def accounts_to_mentions(accounts) - accounts.reorder(:username, :domain).pluck(:username, :domain).map do |username, domain| - domain.blank? ? "@#{username}" : "@#{username}@#{domain}" - end - end end -- cgit