Files
Messenger/server/internal/store/store.go
T
vantablackTea 9d03ea4c51
CI / Go (build + vet + test) (push) Canceled after 0s
CI / Web (build + lint) (push) Canceled after 0s
big update: added reactions, groups, media share
2026-09-27 21:59:48 +03:00

82 lines
1.6 KiB
Go

package store
import (
"time"
"github.com/jackc/pgx/v5/pgxpool"
)
// Store provides database access via a connection pool.
type Store struct {
pool *pgxpool.Pool
}
// New creates a new Store with the given pgx pool.
func New(pool *pgxpool.Pool) *Store {
return &Store{pool: pool}
}
// User represents a user account.
type User struct {
ID int64
Username string
DisplayName string
PasswordHash string
Avatar string
CreatedAt time.Time
}
// Session represents a user session for refresh tokens.
type Session struct {
ID int64
UserID int64
RefreshHash string
ExpiresAt time.Time
CreatedAt time.Time
RevokedAt *time.Time
UserAgent string
IP string
}
// Conversation represents a chat conversation.
type Conversation struct {
ID int64
Type string
Name string
Avatar string
CreatedAt time.Time
}
// MemberInfo describes a conversation participant together with their profile.
type MemberInfo struct {
User User
Role string
JoinedAt time.Time
}
// ConversationSummary provides a conversation with its last message and unread count.
type ConversationSummary struct {
Conversation
LastMessage *Message
UnreadCount int64
}
// Message represents a message sent within a conversation.
type Message struct {
ID int64
ConversationID int64
SenderID int64
Body string
MediaID *int64
CreatedAt time.Time
EditedAt *time.Time
DeletedAt *time.Time
}
// Contact represents a contact relationship between users.
type Contact struct {
OwnerID int64
ContactID int64
CreatedAt time.Time
}