profiles_controller.rb 876 B

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