You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. class Settings::PreferencesController < Settings::BaseController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. def show; end
  6. def update
  7. user_settings.update(user_settings_params.to_h)
  8. if current_user.update(user_params)
  9. I18n.locale = current_user.locale
  10. redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
  11. else
  12. render :show
  13. end
  14. end
  15. private
  16. def user_settings
  17. UserSettingsDecorator.new(current_user)
  18. end
  19. def user_params
  20. params.require(:user).permit(
  21. :locale,
  22. chosen_languages: []
  23. )
  24. end
  25. def user_settings_params
  26. params.require(:user).permit(
  27. :setting_default_privacy,
  28. :setting_default_sensitive,
  29. :setting_default_language,
  30. :setting_unfollow_modal,
  31. :setting_boost_modal,
  32. :setting_delete_modal,
  33. :setting_auto_play_gif,
  34. :setting_display_media,
  35. :setting_expand_spoilers,
  36. :setting_reduce_motion,
  37. :setting_system_font_ui,
  38. :setting_noindex,
  39. :setting_theme,
  40. :setting_hide_network,
  41. :setting_aggregate_reblogs,
  42. notification_emails: %i(follow follow_request reblog favourite mention digest report),
  43. interactions: %i(must_be_follower must_be_following)
  44. )
  45. end
  46. end