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.

30 lines
837 B

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