From 93a5b3f9df7dcf1965525ee2a1202e5f1e07bf05 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 6 Feb 2024 08:33:42 -0500 Subject: [PATCH] Move status serializer chooser to private method (#29030) --- app/controllers/api/v1/statuses_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 064e7632a8..702896db24 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -71,7 +71,7 @@ class Api::V1::StatusesController < Api::BaseController with_rate_limit: true ) - render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer + render json: @status, serializer: serializer_for_status rescue PostStatusService::UnexpectedMentionsError => e unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new( e.accounts, @@ -155,6 +155,10 @@ class Api::V1::StatusesController < Api::BaseController ) end + def serializer_for_status + @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer + end + def pagination_params(core_params) params.slice(:limit).permit(:limit).merge(core_params) end