forked from mtusi2026/mtusi2026lab4
feat: добавить reconciler PostgreSQL и S3
This commit is contained in:
@@ -64,17 +64,21 @@ class MessageRepository:
|
||||
return None
|
||||
|
||||
if attachment_ids:
|
||||
found = set(
|
||||
await session.scalars(
|
||||
select(AttachmentRow.id).where(
|
||||
AttachmentRow.id.in_(attachment_ids),
|
||||
AttachmentRow.chat_id == accessible_chat_id,
|
||||
AttachmentRow.status == 'ready',
|
||||
found = {
|
||||
attachment_id: status
|
||||
for attachment_id, status in (
|
||||
await session.execute(
|
||||
select(AttachmentRow.id, AttachmentRow.status).where(
|
||||
AttachmentRow.id.in_(attachment_ids),
|
||||
AttachmentRow.chat_id == accessible_chat_id,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
if found != set(attachment_ids):
|
||||
).all()
|
||||
}
|
||||
if set(found) != set(attachment_ids):
|
||||
raise NotFound('вложение не найдено')
|
||||
if any(status != 'ready' for status in found.values()):
|
||||
raise Conflict('оригинал вложения недоступен')
|
||||
|
||||
statement = (
|
||||
insert(MessageRow)
|
||||
|
||||
Reference in New Issue
Block a user