feat: add PostgreSQL persistence and sessions

This commit is contained in:
2026-09-24 10:50:20 +03:00
parent 65003b6119
commit 872b69f90e
21 changed files with 2264 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package messenger
import (
"context"
"time"
"gitea.privcloud.tech/dizi/mtusi2026lab2/internal/model"
)
type Repository interface {
Ping(context.Context) error
CreateUser(context.Context, string, string, string) (model.User, error)
UserByID(context.Context, string) (model.User, error)
UserByUsername(context.Context, string) (model.UserCredentials, error)
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)
CreateMessage(context.Context, string, string, string) (model.Message, error)
ListMessages(context.Context, string, string, *model.Position, int) ([]model.Message, bool, error)
}
type SessionStore interface {
Ping(context.Context) error
Create(context.Context, string, time.Duration) (string, time.Time, error)
UserID(context.Context, string) (string, error)
Delete(context.Context, string) error
}
type Passwords interface {
Hash(string) (string, error)
Verify(string, string) (bool, error)
DummyHash() string
}