forked from mtusi2026/mtusi2026lab3
feat(app) lab 3 implemented
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user