Fix #6022 - Prevent nested migrated accounts, or migrations to self (#6026)

master
Eugen Rochko 7 years ago committed by GitHub
parent 573414f728
commit a3b2ea599d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/controllers/settings/migrations_controller.rb
  2. 8
      app/serializers/rest/account_serializer.rb

@ -28,6 +28,7 @@ class Settings::MigrationsController < ApplicationController
end
def migration_account_changed?
current_account.moved_to_account_id != @migration.account&.id
current_account.moved_to_account_id != @migration.account&.id &&
current_account.id != @migration.account&.id
end
end

@ -7,9 +7,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
:note, :url, :avatar, :avatar_static, :header, :header_static,
:followers_count, :following_count, :statuses_count
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved?
delegate :moved?, to: :object
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
def id
object.id.to_s
@ -38,4 +36,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
def header_static
full_asset_url(object.header_static_url)
end
def moved_and_not_nested?
object.moved? && object.moved_to_account.moved_to_account_id.nil?
end
end

Loading…
Cancel
Save