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.

34 lines
892 B

  1. # frozen_string_literal: true
  2. class Settings::MigrationsController < Settings::BaseController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. def show
  6. @migration = Form::Migration.new(account: current_account.moved_to_account)
  7. end
  8. def update
  9. @migration = Form::Migration.new(resource_params)
  10. if @migration.valid? && migration_account_changed?
  11. current_account.update!(moved_to_account: @migration.account)
  12. ActivityPub::UpdateDistributionWorker.perform_async(current_account.id)
  13. redirect_to settings_migration_path, notice: I18n.t('migrations.updated_msg')
  14. else
  15. render :show
  16. end
  17. end
  18. private
  19. def resource_params
  20. params.require(:migration).permit(:acct)
  21. end
  22. def migration_account_changed?
  23. current_account.moved_to_account_id != @migration.account&.id &&
  24. current_account.id != @migration.account&.id
  25. end
  26. end