forked from mtusi2026/mtusi2026lab5
lab5: брокер RabbitMQ, worker и асинхронная обработка
This commit is contained in:
@@ -97,12 +97,15 @@ export class MessagesService {
|
||||
// чужую заявку сняли между нашими двумя запросами (503).
|
||||
if (!(await this.idempotency.isMember(chatId, currentUser.id)))
|
||||
throw new NotFoundException();
|
||||
// Unknown, foreign-chat or unfinished attachment: not found.
|
||||
if (
|
||||
ids.length > 0 &&
|
||||
!(await this.attachments.allLinkable(chatId, ids))
|
||||
)
|
||||
throw new NotFoundException();
|
||||
// Unknown or foreign-chat ids are 404; an attachment whose
|
||||
// processing failed is a conflict, not a missing object.
|
||||
const linkState =
|
||||
ids.length > 0
|
||||
? await this.attachments.linkState(chatId, ids)
|
||||
: 'ok';
|
||||
if (linkState === 'failed')
|
||||
throw new ConflictException('Attachment processing failed');
|
||||
if (linkState === 'missing') throw new NotFoundException();
|
||||
this.metrics.increment('idempotency.claim_lost');
|
||||
throw new ServiceUnavailableException(
|
||||
'Idempotency key could not be claimed',
|
||||
|
||||
Reference in New Issue
Block a user