闭社主体 forked from https://github.com/tootsuite/mastodon
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.

48 lines
1.1 KiB

  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_default_sensitive,
  29. :setting_unfollow_modal,
  30. :setting_boost_modal,
  31. :setting_delete_modal,
  32. :setting_auto_play_gif,
  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