about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2020-02-18 02:43:47 -0600
committermultiple creatures <dev@multiple-creature.party>2020-02-18 02:43:47 -0600
commite4633a1150450396157640f5262393bb52db280b (patch)
tree4d5666c64f9e502b84700983275553c1d9030428 /app/models
parent0f3b01eaab82325baaf1c7a4c75a322d3c21a67f (diff)
move defang toggle to preferences instead of profile
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/user.rb6
2 files changed, 6 insertions, 2 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 6f5a11ce0..20b93ddc5 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -136,8 +136,6 @@ class Account < ApplicationRecord
            :staff?,
            :can_moderate?,
            :defanged?,
-           :defanged,
-           :defanged=,
            :locale,
 
            :default_language,
diff --git a/app/models/user.rb b/app/models/user.rb
index 00e2af458..7f47ecc3f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -119,6 +119,7 @@ class User < ApplicationRecord
 
   before_validation :sanitize_languages
   before_create :set_approved
+  before_save :set_last_fanged_at
 
   # This avoids a deprecation warning from Rails 5.1
   # It seems possible that a future release of devise-two-factor will
@@ -532,6 +533,11 @@ class User < ApplicationRecord
     self.approved = open_registrations? || valid_invitation? || external?
   end
 
+  def set_last_fanged_at
+    return unless defanged_changed? && !last_fanged_at_changed?
+    self.last_fanged_at = (defanged? ? nil : Time.now.utc)
+  end
+
   def open_registrations?
     Setting.registrations_mode == 'open'
   end