闭社主体 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.

27 lines
894 B

  1. class Settings::PreferencesController < ApplicationController
  2. layout 'auth'
  3. before_action :authenticate_user!
  4. def show
  5. end
  6. def update
  7. current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
  8. current_user.settings(:notification_emails).reblog = user_params[:notification_emails][:reblog] == '1'
  9. current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
  10. current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1'
  11. if current_user.save
  12. redirect_to settings_preferences_path, notice: 'Changes successfully saved!'
  13. else
  14. render action: :show
  15. end
  16. end
  17. private
  18. def user_params
  19. params.require(:user).permit(notification_emails: [:follow, :reblog, :favourite, :mention])
  20. end
  21. end