forked from mtusi2026/mtusi2026lab6
51 lines
1.9 KiB
Go
51 lines
1.9 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"gitflic.ru/project/relationskatie/mtusi2026lab1-ashchkl/internal/domain"
|
|
)
|
|
|
|
type UsersService interface {
|
|
Register(ctx context.Context, username, displayName, password string) (domain.User, error)
|
|
Me(ctx context.Context, callerID string) (domain.User, error)
|
|
}
|
|
|
|
type ChatsService interface {
|
|
Create(ctx context.Context, callerID, title string, memberIDs []string) (domain.Chat, error)
|
|
Get(ctx context.Context, callerID, chatID string) (domain.Chat, error)
|
|
List(ctx context.Context, callerID, cursor string, limit int) (domain.Page[domain.Chat], error)
|
|
}
|
|
|
|
type MessagesService interface {
|
|
Send(ctx context.Context, callerID, chatID, idempotencyKey, text string, attachmentIDs []string) (domain.Message, error)
|
|
List(ctx context.Context, callerID, chatID, cursor string, limit int) (domain.Page[domain.Message], error)
|
|
}
|
|
|
|
// VariantOriginal — вариант содержимого по умолчанию.
|
|
const VariantOriginal = "original"
|
|
|
|
// UploadInput — параметры загрузки файла. Body читается не дальше лимита размера.
|
|
type UploadInput struct {
|
|
CallerID string
|
|
ChatID string
|
|
Filename string
|
|
ContentType string
|
|
ContentLength int64
|
|
Body io.Reader
|
|
}
|
|
|
|
type AttachmentsService interface {
|
|
Upload(ctx context.Context, in UploadInput) (domain.Attachment, error)
|
|
Get(ctx context.Context, callerID, attachmentID string) (domain.Attachment, error)
|
|
// Content возвращает метаданные и поток байтов. Поток обязательно закрыть.
|
|
Content(ctx context.Context, callerID, attachmentID, variant string) (domain.Attachment, io.ReadCloser, error)
|
|
}
|
|
|
|
type AuthService interface {
|
|
Login(ctx context.Context, username, password string) (domain.Session, error)
|
|
Authenticate(ctx context.Context, token string) (userID string, err error)
|
|
Logout(ctx context.Context, token string) error
|
|
}
|