ЛР4 - БВТ2303 - Голиков- на 4 #13

Closed
Maximillan_Mercer wants to merge 64 commits from Maximillan_Mercer/mtusi2026lab4-fork:solution/BVT2303-Golikov into main
Showing only changes of commit 6cc487b0f3 - Show all commits
+8 -1
View File
@@ -108,7 +108,10 @@ func (r *MessageRepo) CreateIdempotent(
}, nil
}
// 4) Слот наш — вставляем сообщение в той же транзакции.
if err := r.validateAttachments(ctx, tx, fresh.ChatID, fresh.AttachmentIDs); err != nil {
return nil, err
}
if _, err := tx.Exec(ctx, `
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
VALUES ($1::uuid, $2::uuid, $3::uuid, $4, $5)
@@ -122,6 +125,10 @@ func (r *MessageRepo) CreateIdempotent(
return nil, mapError(err)
}
if err := r.linkAttachments(ctx, tx, fresh.ID, fresh.AttachmentIDs); err != nil {
return nil, err
}
if err := tx.Commit(ctx); err != nil {
return nil, mapError(err)
}