about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-08 09:59:14 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-08 12:46:17 -0500
commit4dfc40324b1f3b20550982621501e162d2ed3bed (patch)
tree1578cba8809b7db27dc82f4d439471194d5fad31 /app/models/account.rb
parentd019e55b7bc496d3c4d942fb4ffe65bb7e149249 (diff)
add new `reject unknown` policy option to prevent spam & harassment from large/undermoderated servers
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 6528a7ae9..97b0e93e4 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -51,6 +51,7 @@
 #  gently                  :boolean          default(FALSE), not null
 #  kobold                  :boolean          default(FALSE), not null
 #  froze                   :boolean
+#  known                   :boolean          default(FALSE), not null
 #
 
 class Account < ApplicationRecord
@@ -213,6 +214,14 @@ class Account < ApplicationRecord
     ResolveAccountService.new.call(acct)
   end
 
+  def mark_unknown!
+    update!(known: false)
+  end
+
+  def mark_known!
+    update!(known: true)
+  end
+
   def force_unlisted!
     transaction do
       update!(force_unlisted: true)
@@ -557,6 +566,7 @@ class Account < ApplicationRecord
 
   before_create :generate_keys
   before_create :set_domain_from_inbox_url
+  before_create :set_known, if: :local?
   before_validation :prepare_contents, if: :local?
   before_validation :prepare_username, on: :create
   before_destroy :clean_feed_manager
@@ -579,6 +589,10 @@ class Account < ApplicationRecord
     nil
   end
 
+  def set_known
+    self.known = true
+  end
+
   def generate_keys
     return unless local? && !Rails.env.test?