1
0
Fork 0
forked from fedi/mastodon

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

This commit is contained in:
Eugen Rochko 2017-12-14 21:35:30 +01:00 committed by GitHub
parent 573414f728
commit a3b2ea599d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -28,6 +28,7 @@ class Settings::MigrationsController < ApplicationController
end end
def migration_account_changed? 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
end end

View file

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