Files
2026-10-06 22:45:35 +03:00

29 lines
1.2 KiB
Go

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 string) (domain.Message, error)
ListMessages(ctx context.Context, chatID string, after *domain.Position, limit int) ([]domain.Message, error)
}