From 90802c9acd64d4ad6de05fae13efd3a97b4c6043 Mon Sep 17 00:00:00 2001
From: multiple creatures <dev@multiple-creature.party>
Date: Wed, 5 Feb 2020 13:29:17 -0600
Subject: move rando check into the account model so it can be reused by other
 anti-harassment tools

---
 app/lib/activitypub/activity/follow.rb | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

(limited to 'app/lib/activitypub')

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