profiles_controller.rb 686 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. class Settings::ProfilesController < Settings::BaseController
  3. before_action :set_account
  4. def show
  5. @account.build_fields
  6. end
  7. def update
  8. if UpdateAccountService.new.call(@account, account_params)
  9. ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
  10. redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
  11. else
  12. @account.build_fields
  13. render :show
  14. end
  15. end
  16. private
  17. def account_params
  18. params.require(:account).permit(:display_name, :note, :avatar, :header, :bot, fields_attributes: [:name, :value])
  19. end
  20. def set_account
  21. @account = current_account
  22. end
  23. end