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.

46 lines
1.1 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. filtered_languages: []
  21. )
  22. end
  23. def user_settings_params
  24. params.require(:user).permit(
  25. :setting_default_privacy,
  26. :setting_default_sensitive,
  27. :setting_unfollow_modal,
  28. :setting_boost_modal,
  29. :setting_favourite_modal,
  30. :setting_delete_modal,
  31. :setting_auto_play_gif,
  32. :setting_reduce_motion,
  33. :setting_system_font_ui,
  34. :setting_noindex,
  35. notification_emails: %i(follow follow_request reblog favourite mention digest),
  36. interactions: %i(must_be_follower must_be_following)
  37. )
  38. end
  39. end