forked from mtusi2026/mtusi2026lab7
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/messenger/attachment"
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/model"
|
|
)
|
|
|
|
type UserRepository interface {
|
|
CreateUser(context.Context, string, string, string) (model.User, error)
|
|
UserByID(context.Context, string) (model.User, error)
|
|
UserByUsername(context.Context, string) (model.UserCredentials, error)
|
|
UpdatePasswordHash(context.Context, string, string, string) (bool, error)
|
|
}
|
|
|
|
type ChatRepository interface {
|
|
CreateChat(context.Context, string, []string, string) (model.Chat, error)
|
|
ChatForUser(context.Context, string, string) (model.Chat, error)
|
|
ListChats(context.Context, string, *model.Position, int) ([]model.Chat, bool, error)
|
|
}
|
|
|
|
type MessageRepository interface {
|
|
CreateMessage(context.Context, string, string, string, []string, string, time.Duration) (model.Message, bool, error)
|
|
ListMessages(context.Context, string, string, *model.Position, int) ([]model.Message, bool, error)
|
|
}
|
|
|
|
type AttachmentService interface {
|
|
Upload(context.Context, attachment.Upload) (model.Attachment, error)
|
|
Metadata(context.Context, string, string) (model.Attachment, error)
|
|
Content(context.Context, string, string, string) (attachment.Content, error)
|
|
}
|
|
|
|
type HealthChecker interface {
|
|
Ping(context.Context) error
|
|
}
|
|
|
|
type SessionStore interface {
|
|
HealthChecker
|
|
Create(context.Context, string, time.Duration) (string, time.Time, error)
|
|
UserID(context.Context, string) (string, error)
|
|
Delete(context.Context, string) error
|
|
}
|
|
|
|
type PasswordService interface {
|
|
Hash(string) (string, error)
|
|
Verify(string, string) (bool, error)
|
|
NeedsRehash(string) (bool, error)
|
|
DummyHash() string
|
|
}
|
|
|
|
type LoginLimiter interface {
|
|
Allow(context.Context, string, string) (bool, time.Duration, error)
|
|
}
|