diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-01-18 16:25:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 16:25:31 +0100 |
commit | 0405be69d265b81a41be9c253e4b50aa6c8e1ee9 (patch) | |
tree | 1a13b4e5132995bd125d9626384b78905cc50cf8 /app/serializers | |
parent | d4f590d6bba173bb0861e9babc7830bdc57d55d6 (diff) |
Fix REST API serializer for Account not including `moved` when the moved account has itself moved (#22483)
Instead of cutting immediately, cut after one recursion.
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/rest/account_serializer.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index e521dacaa..6582b5bcf 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -16,6 +16,16 @@ class REST::AccountSerializer < ActiveModel::Serializer attribute :silenced, key: :limited, if: :silenced? attribute :noindex, if: :local? + class AccountDecorator < SimpleDelegator + def self.model_name + Account.model_name + end + + def moved? + false + end + end + class FieldSerializer < ActiveModel::Serializer include FormattingHelper @@ -85,7 +95,7 @@ class REST::AccountSerializer < ActiveModel::Serializer end def moved_to_account - object.suspended? ? nil : object.moved_to_account + object.suspended? ? nil : AccountDecorator.new(object.moved_to_account) end def emojis @@ -111,6 +121,6 @@ class REST::AccountSerializer < ActiveModel::Serializer delegate :suspended?, :silenced?, :local?, to: :object def moved_and_not_nested? - object.moved? && object.moved_to_account.moved_to_account_id.nil? + object.moved? end end |