Files
mtusi2026lab2/internal/usecase/chat/repository.go
T
2026-10-06 19:51:28 +03:00

27 lines
1.0 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 {
CreateUser(ctx context.Context, username, displayName 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)
}