mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 00:08:46 +00:00
Merge commit 'aaa58d4807377e04649499ebee91757b16b9a007' into glitch-soc/merge-upstream
Conflicts: - `.github/workflows/build-security.yml`: Changes were already cherry-picked and adapted in glitch-soc. Kept glitch-soc's version. - `Gemfile.lock`: Changes were already cherry-picked and updated further in glitch-soc. Kept glitch-soc's version. - `lib/mastodon/version.rb`: Changes were already cherry-picked and updated further in glitch-soc. Kept glitch-soc's version.
This commit is contained in:
@@ -72,13 +72,9 @@ 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,
|
||||
serializer: REST::AccountSerializer
|
||||
)
|
||||
render json: { error: e.message, unexpected_accounts: unexpected_accounts }, status: 422
|
||||
render json: unexpected_accounts_error_json(e), status: 422
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -158,6 +154,21 @@ class Api::V1::StatusesController < Api::BaseController
|
||||
)
|
||||
end
|
||||
|
||||
def serializer_for_status
|
||||
@status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
||||
end
|
||||
|
||||
def unexpected_accounts_error_json(error)
|
||||
{
|
||||
error: error.message,
|
||||
unexpected_accounts: serialized_accounts(error.accounts),
|
||||
}
|
||||
end
|
||||
|
||||
def serialized_accounts(accounts)
|
||||
ActiveModel::Serializer::CollectionSerializer.new(accounts, serializer: REST::AccountSerializer)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user