From e4bf427f655981966a13c03dd4ab4417545dfa15 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 17:10:05 +0100 Subject: [PATCH] Index returned entries by id --- app/controllers/api/v1/accounts_controller.rb | 2 +- app/controllers/api/v1/statuses_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index be7b302d3be..95540199fcd 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -22,7 +22,7 @@ class Api::V1::AccountsController < Api::BaseController override_rate_limit_headers :follow, family: :follows def index - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts.map { |account| ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer, scope: current_user, scope_name: :current_user).as_json }.index_by { |account| account[:id] } end def show diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 36a9ec6325b..fb99d3de7f7 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -27,7 +27,7 @@ class Api::V1::StatusesController < Api::BaseController def index @statuses = cache_collection(@statuses, Status) - render json: @statuses, each_serializer: REST::StatusSerializer + render json: @statuses.map { |status| ActiveModelSerializers::SerializableResource.new(status, serializer: REST::StatusSerializer, scope: current_user, scope_name: :current_user).as_json }.index_by { |status| status[:id] } end def show