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.

53 lines
1.3 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 settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
  9. else
  10. render :show
  11. end
  12. end
  13. private
  14. def user_settings
  15. UserSettingsDecorator.new(current_user)
  16. end
  17. def user_params
  18. params.require(:user).permit(
  19. :locale,
  20. chosen_languages: []
  21. )
  22. end
  23. def user_settings_params
  24. params.require(:user).permit(
  25. :setting_default_privacy,
  26. :setting_default_sensitive,
  27. :setting_default_language,
  28. :setting_unfollow_modal,
  29. :setting_boost_modal,
  30. :setting_favourite_modal,
  31. :setting_delete_modal,
  32. :setting_auto_play_gif,
  33. :setting_display_media,
  34. :setting_expand_spoilers,
  35. :setting_reduce_motion,
  36. :setting_system_font_ui,
  37. :setting_noindex,
  38. :setting_hide_network,
  39. :setting_hide_followers_count,
  40. :setting_aggregate_reblogs,
  41. :setting_show_application,
  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