lab3 done

This commit is contained in:
Khakimov Dmitrij
2026-10-28 21:48:04 +03:00
parent ec540a1a72
commit a7bedda183
81 changed files with 4202 additions and 10 deletions
+28
View File
@@ -0,0 +1,28 @@
package chat
import (
"context"
"errors"
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/domain"
)
var (
ErrUsernameTaken = errors.New("username is already taken")
ErrUserNotFound = errors.New("user not found")
ErrChatNotFound = errors.New("chat not found")
ErrNotMember = errors.New("user is not a chat member")
)
// Repository is the persistence port required by the chat use case.
type Repository interface {
Ready(ctx context.Context) error
UserByUsername(ctx context.Context, username string) (domain.User, string, bool, error)
CreateUser(ctx context.Context, username, displayName, passwordHash string) (domain.User, error)
User(ctx context.Context, id string) (domain.User, bool, error)
CreateChat(ctx context.Context, title string, memberIDs []string) (domain.Chat, error)
ChatForUser(ctx context.Context, chatID, userID string) (domain.Chat, error)
ListChats(ctx context.Context, userID string, after *domain.Position, limit int) ([]domain.Chat, error)
CreateMessage(ctx context.Context, chatID, senderID, text, key string) (domain.Message, error)
ListMessages(ctx context.Context, chatID string, after *domain.Position, limit int) ([]domain.Message, error)
}