]> cat aescling's git repositories - mastodon.git/blobdiff - app/controllers/settings/preferences_controller.rb
Allow selecting default posting language instead of auto-detect (#7828)
[mastodon.git] / app / controllers / settings / preferences_controller.rb
index 5be8719aef9a0a8a130d9a64694a848e4c608e0e..e2cb131671d3e3ab70b3867aa093f601338142c6 100644 (file)
@@ -1,29 +1,53 @@
 # frozen_string_literal: true
 
 class Settings::PreferencesController < ApplicationController
-  layout 'auth'
+  layout 'admin'
 
   before_action :authenticate_user!
 
-  def show
-  end
+  def show; end
 
   def update
-    current_user.settings(:notification_emails).follow    = user_params[:notification_emails][:follow]    == '1'
-    current_user.settings(:notification_emails).reblog    = user_params[:notification_emails][:reblog]    == '1'
-    current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
-    current_user.settings(:notification_emails).mention   = user_params[:notification_emails][:mention]   == '1'
+    user_settings.update(user_settings_params.to_h)
 
-    if current_user.update(user_params.except(:notification_emails))
+    if current_user.update(user_params)
+      I18n.locale = current_user.locale
       redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
     else
-      render action: :show
+      render :show
     end
   end
 
   private
 
+  def user_settings
+    UserSettingsDecorator.new(current_user)
+  end
+
   def user_params
-    params.require(:user).permit(:locale, notification_emails: [:follow, :reblog, :favourite, :mention])
+    params.require(:user).permit(
+      :locale,
+      chosen_languages: []
+    )
+  end
+
+  def user_settings_params
+    params.require(:user).permit(
+      :setting_default_privacy,
+      :setting_default_sensitive,
+      :setting_default_language,
+      :setting_unfollow_modal,
+      :setting_boost_modal,
+      :setting_delete_modal,
+      :setting_auto_play_gif,
+      :setting_display_sensitive_media,
+      :setting_reduce_motion,
+      :setting_system_font_ui,
+      :setting_noindex,
+      :setting_theme,
+      :setting_hide_network,
+      notification_emails: %i(follow follow_request reblog favourite mention digest),
+      interactions: %i(must_be_follower must_be_following)
+    )
   end
 end
This page took 0.038975 seconds and 3 git commands to generate.