where i deviate from standard mastodon assets
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.

preferences_controller.rb 1.6KB

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