about summary refs log tree commit diff
path: root/app
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
parent0f3b01eaab82325baaf1c7a4c75a322d3c21a67f (diff)
move defang toggle to preferences instead of profile
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/preferences_controller.rb1
-rw-r--r--app/controllers/settings/profiles_controller.rb2
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/user.rb6
-rw-r--r--app/views/settings/preferences/show.html.haml6
-rw-r--r--app/views/settings/profiles/show.html.haml6
6 files changed, 14 insertions, 9 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 6e3f22d7a..c64ae9ab7 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -55,6 +55,7 @@ class Settings::PreferencesController < Settings::BaseController
       :filter_timelines_only,
       :monsterpit_api,
       :allow_unknown_follows,
+      :defanged,
       chosen_languages: []
     )
   end
diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb
index dab613085..6b3f0d311 100644
--- a/app/controllers/settings/profiles_controller.rb
+++ b/app/controllers/settings/profiles_controller.rb
@@ -25,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController
   private
 
   def account_params
-    params.require(:account).permit(:display_name, :note, :avatar, :header, :replies, :locked, :hidden, :unlisted, :block_anon, :gently, :kobold, :adult_content, :bot, :discoverable, :filter_undescribed, :user_defanged, fields_attributes: [:name, :value])
+    params.require(:account).permit(:display_name, :note, :avatar, :header, :replies, :locked, :hidden, :unlisted, :block_anon, :gently, :kobold, :adult_content, :bot, :discoverable, :filter_undescribed, fields_attributes: [:name, :value])
   end
 
   def set_account
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
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index 4d4941a2e..c51f91bde 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -11,6 +11,12 @@
 = simple_form_for current_user, url: settings_preferences_path, html: { method: :put } do |f|
   = render 'shared/error_messages', object: current_user
 
+  - if current_user.can_moderate?
+    %hr/
+
+    .fields-group
+      = f.input :defanged, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.defanged')
+
   %hr#settings_publishing/
 
   .fields-group
diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml
index ba2fd7495..4fabfb9f4 100644
--- a/app/views/settings/profiles/show.html.haml
+++ b/app/views/settings/profiles/show.html.haml
@@ -18,12 +18,6 @@
 
       = f.input :avatar, wrapper: :with_label, input_html: { accept: AccountAvatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(AccountAvatar::LIMIT))
 
-  - if @account.user_can_moderate?
-    %hr.spacer/
-
-    .fields-group
-      = f.input :user_defanged, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.user_defanged')
-
   %hr.spacer/
 
   .fields-group