forked from mtusi2026/mtusi2026lab5
- RabbitMQ quorum queue, persistent messages and publisher confirms - S3 staging plus PostgreSQL attachments/jobs outbox transaction - worker variants (thumbnail, crop, optimized WebP), DB lease and lease sweeper - jittered retry, permanent failures, explicit replay and admission cap - deterministic crash hooks, resilience script and evidence for grade 4 - async-aware custom tests, oversized pixel case, docs and changelog
83 lines
2.8 KiB
Go
83 lines
2.8 KiB
Go
// Package model defines the JSON-facing domain types shared by handlers,
|
|
// storage and the public contract.
|
|
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/common"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display_name"`
|
|
PasswordHash string `json:"-"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
func (u User) GetID() uuid.UUID { return u.ID }
|
|
func (u User) GetCreatedAt() time.Time { return time.Time(u.CreatedAt) }
|
|
|
|
type Chat struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Title string `json:"title"`
|
|
MemberIDs []uuid.UUID `json:"member_ids"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
func (c Chat) GetID() uuid.UUID { return c.ID }
|
|
func (c Chat) GetCreatedAt() time.Time { return time.Time(c.CreatedAt) }
|
|
|
|
type Message struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ChatID uuid.UUID `json:"chat_id"`
|
|
SenderID uuid.UUID `json:"sender_id"`
|
|
Text string `json:"text"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
AttachmentIDs []uuid.UUID `json:"attachment_ids"`
|
|
}
|
|
|
|
func (m Message) GetID() uuid.UUID { return m.ID }
|
|
func (m Message) GetCreatedAt() time.Time { return time.Time(m.CreatedAt) }
|
|
|
|
type Attachment struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ChatID uuid.UUID `json:"chat_id"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
Filename string `json:"filename"`
|
|
ContentType string `json:"content_type"`
|
|
SizeBytes int64 `json:"size_bytes"`
|
|
SHA256 string `json:"sha256"`
|
|
Status string `json:"status"`
|
|
Variants []Variant `json:"variants"`
|
|
ErrorCode *string `json:"error_code"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
UpdatedAt common.RFCFormTime `json:"updated_at"`
|
|
|
|
// ObjectKey and StagingKey are internal and never serialized.
|
|
ObjectKey string `json:"-"`
|
|
StagingKey string `json:"-"`
|
|
PipelineVersion int `json:"-"`
|
|
}
|
|
|
|
func (a Attachment) GetID() uuid.UUID { return a.ID }
|
|
func (a Attachment) GetCreatedAt() time.Time { return time.Time(a.CreatedAt) }
|
|
|
|
type Variant struct {
|
|
Name string `json:"name"`
|
|
ContentType string `json:"content_type"`
|
|
SizeBytes int64 `json:"size_bytes"`
|
|
Width int `json:"width"`
|
|
Height int `json:"height"`
|
|
SHA256 string `json:"sha256"`
|
|
}
|
|
|
|
type Session struct {
|
|
Token string `json:"token"`
|
|
TokenType string `json:"token_type"`
|
|
ExpiresAt common.RFCFormTime `json:"expires_at"`
|
|
User User `json:"user"`
|
|
}
|