feat(app) lab 3 implemented

This commit is contained in:
imadev
2026-10-30 18:11:30 +03:00
parent f731f9b460
commit 48a616e910
57 changed files with 1390 additions and 303 deletions
+3 -6
View File
@@ -5,15 +5,12 @@ import (
"errors"
"time"
"gitflic.ru/project/bulla-max/mtusi2026lab2/internal/common"
"gitflic.ru/project/bulla-max/mtusi2026lab2/internal/model"
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/common"
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/model"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
)
// CreateChat inserts the chat and every membership row in one transaction.
// Any unknown member aborts the whole transaction, so a partially created chat
// can never be observed.
func (s *Store) CreateChat(ctx context.Context, title string, memberIDs []uuid.UUID) (model.Chat, error) {
ctx, cancel := s.withTimeout(ctx)
defer cancel()
@@ -22,7 +19,7 @@ func (s *Store) CreateChat(ctx context.Context, title string, memberIDs []uuid.U
if err != nil {
return model.Chat{}, dbError(err)
}
defer func() { _ = tx.Rollback(context.Background()) }()
defer rollback(tx)
for _, memberID := range memberIDs {
var exists int