about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/lib/activitypub/activity/follow.rb8
-rw-r--r--app/models/account.rb12
2 files changed, 13 insertions, 7 deletions
diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb
index 9e94857a7..11eed5fe3 100644
--- a/app/lib/activitypub/activity/follow.rb
+++ b/app/lib/activitypub/activity/follow.rb
@@ -14,7 +14,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
       return
     end
 
-    if !target_account.user.allow_unknown_follows? && !(target_account.following?(@account) || ever_mentioned_by?(target_account))
+    if !target_account.user.allow_unknown_follows? && !@account.ever_interacted_with(target_account)
       reject_follow_request!(target_account)
       return
     end
@@ -39,10 +39,4 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
     json = Oj.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
     ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url)
   end
-
-  private
-
-  def ever_mentioned_by?(target_account)
-    Status.joins(:mentions).merge(target_account.mentions).where(account_id: @account.id).exists?
-  end
 end
diff --git a/app/models/account.rb b/app/models/account.rb
index 8ea4ec288..20181ed57 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -455,6 +455,18 @@ class Account < ApplicationRecord
     shared_inbox_url.presence || inbox_url
   end
 
+  def ever_mentioned_by?(target_account)
+    return false if target_account.nil?
+
+    Status.joins(:mentions).merge(target_account.mentions).where(account_id: id).exists?
+  end
+
+  def ever_interacted_with?(target_account)
+    return false if target_account.nil?
+
+    target_account.following?(this) || ever_mentioned_by?(target_account)
+  end
+
   class Field < ActiveModelSerializers::Model
     attributes :name, :value, :verified_at, :account, :errors