about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2020-02-05 13:29:17 -0600
committermultiple creatures <dev@multiple-creature.party>2020-02-05 13:29:17 -0600
commit90802c9acd64d4ad6de05fae13efd3a97b4c6043 (patch)
tree615eecbba4fb5200b4664c334f5c66283107b966 /app/models/account.rb
parenteec87c190b42b4b4c50f55594cb16ccc9db28c17 (diff)
move rando check into the account model so it can be reused by other anti-harassment tools
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb12
1 files changed, 12 insertions, 0 deletions
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