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.

42 lines
970 B

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