Merge remote-tracking branch 'parent/main' into upstream-20230209
This commit is contained in:
commit
05e52a09a8
188 changed files with 2810 additions and 1295 deletions
|
@ -84,13 +84,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
|
||||
|
@ -174,6 +170,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue