From 4dfc40324b1f3b20550982621501e162d2ed3bed Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Thu, 8 Aug 2019 09:59:14 -0500 Subject: add new `reject unknown` policy option to prevent spam & harassment from large/undermoderated servers --- app/models/account.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/models/account.rb') 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? -- cgit