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.

44 lines
975 B

  1. # frozen_string_literal: true
  2. class Settings::PreferencesController < ApplicationController
  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. filtered_languages: []
  23. )
  24. end
  25. def user_settings_params
  26. params.require(:user).permit(
  27. :setting_default_privacy,
  28. :setting_boost_modal,
  29. :setting_delete_modal,
  30. :setting_auto_play_gif,
  31. notification_emails: %i(follow follow_request reblog favourite mention digest),
  32. interactions: %i(must_be_follower must_be_following)
  33. )
  34. end
  35. end