logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

preferences_controller.rb (1187B)


  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_display_sensitive_media,
  34. :setting_reduce_motion,
  35. :setting_system_font_ui,
  36. :setting_noindex,
  37. :setting_theme,
  38. notification_emails: %i(follow follow_request reblog favourite mention digest),
  39. interactions: %i(must_be_follower must_be_following)
  40. )
  41. end
  42. end