about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/process_mentions_service.rb34
1 files changed, 18 insertions, 16 deletions
diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb
index 86c3be70c..85a22128c 100644
--- a/app/services/process_mentions_service.rb
+++ b/app/services/process_mentions_service.rb
@@ -7,34 +7,36 @@ class ProcessMentionsService < BaseService
   # local mention pointers, send Salmon notifications to mentioned
   # remote users
   # @param [Status] status
-  def call(status, skip_notify: false)
+  def call(status, skip_process: false, skip_notify: false)
     return unless status.local? && !status.draft?
 
     @status  = status
     mentions = Mention.where(status: status).to_a
 
-    status.text = status.text.gsub(Account::MENTION_RE) do |match|
-      username, domain  = Regexp.last_match(1).split('@')
-      mentioned_account = Account.find_remote(username, domain)
+    unless skip_process
+      status.text = status.text.gsub(Account::MENTION_RE) do |match|
+        username, domain  = Regexp.last_match(1).split('@')
+        mentioned_account = Account.find_remote(username, domain)
 
-      next match unless domain.nil? || '.'.in?(domain)
+        next match unless domain.nil? || '.'.in?(domain)
 
-      if mention_undeliverable?(mentioned_account)
-        begin
-          mentioned_account = resolve_account_service.call(Regexp.last_match(1))
-        rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
-          mentioned_account = nil
+        if mention_undeliverable?(mentioned_account)
+          begin
+            mentioned_account = resolve_account_service.call(Regexp.last_match(1))
+          rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
+            mentioned_account = nil
+          end
         end
-      end
 
-      next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended?
+        next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended?
 
-      mentions << mentioned_account.mentions.where(status: status).first_or_create(status: status)
+        mentions << mentioned_account.mentions.where(status: status).first_or_create(status: status)
 
-      "@#{mentioned_account.acct}"
-    end
+        "@#{mentioned_account.acct}"
+      end
 
-    status.save!
+      status.save!
+    end
 
     return if skip_notify
     mentions.uniq.each { |mention| create_notification(mention) }