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.

60 lines
1.5 KiB

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