Skip to content

Commit

Permalink
Fix reblog reactions being hydrated improperly
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEssem authored and arachnist committed Aug 12, 2024
1 parent 27b187d commit cb53239
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/lib/status_cache_hydrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def hydrate_non_reblog_payload(empty_payload, account_id)
payload[:bookmarked] = Bookmark.exists?(account_id: account_id, status_id: @status.id)
payload[:pinned] = StatusPin.exists?(account_id: account_id, status_id: @status.id) if @status.account_id == account_id
payload[:filtered] = mapped_applied_custom_filter(account_id, @status)
payload[:reactions] = serialized_reactions(account_id)
payload[:reactions] = serialized_reactions(account_id, @status)

if payload[:poll]
payload[:poll][:voted] = @status.account_id == account_id
Expand All @@ -58,7 +58,7 @@ def hydrate_reblog_payload(empty_payload, account_id)
payload[:reblog][:bookmarked] = Bookmark.exists?(account_id: account_id, status_id: @status.reblog_of_id)
payload[:reblog][:pinned] = StatusPin.exists?(account_id: account_id, status_id: @status.reblog_of_id) if @status.reblog.account_id == account_id
payload[:reblog][:filtered] = payload[:filtered]
payload[:reblog][:reactions] = serialized_reactions(account_id)
payload[:reblog][:reactions] = serialized_reactions(account_id, @status.reblog)

if payload[:reblog][:poll]
if @status.reblog.account_id == account_id
Expand All @@ -73,7 +73,6 @@ def hydrate_reblog_payload(empty_payload, account_id)

payload[:favourited] = payload[:reblog][:favourited]
payload[:reblogged] = payload[:reblog][:reblogged]
payload[:reactions] = payload[:reblog][:reactions]
end
end

Expand All @@ -90,8 +89,8 @@ def serialized_filter(filter)
).as_json
end

def serialized_reactions(account_id)
reactions = @status.reactions(account_id)
def serialized_reactions(account_id, status)
reactions = status.reactions(account_id)
ActiveModelSerializers::SerializableResource.new(
reactions,
each_serializer: REST::ReactionSerializer,
Expand Down

0 comments on commit cb53239

Please sign in to comment.