refactor: isolate attachment lifecycle

This commit is contained in:
2026-10-09 13:13:59 +03:00
parent ad36ab8a92
commit cc4ac1ddd7
33 changed files with 1672 additions and 982 deletions
+18
View File
@@ -0,0 +1,18 @@
package model
import "errors"
var (
ErrNotFound = errors.New("not found")
ErrConflict = errors.New("conflict")
ErrInvalidMembers = errors.New("invalid members")
ErrInvalidCursor = errors.New("invalid cursor")
ErrIdempotencyConflict = errors.New("idempotency conflict")
ErrInvalidToken = errors.New("invalid token")
ErrSessionNotFound = errors.New("session not found")
ErrInvalidInput = errors.New("invalid input")
ErrUnsupportedMedia = errors.New("unsupported media")
ErrPayloadTooLarge = errors.New("payload too large")
ErrCapacity = errors.New("capacity exhausted")
ErrUnavailable = errors.New("dependency unavailable")
)
+27 -13
View File
@@ -5,6 +5,12 @@ import (
"time"
)
const (
AttachmentPending = "pending"
AttachmentReady = "ready"
AttachmentDeleting = "deleting"
)
const timestampLayout = "2006-01-02T15:04:05.000000Z"
type User struct {
@@ -36,19 +42,27 @@ type Message struct {
}
type Attachment struct {
ID string `json:"id"`
ChatID string `json:"chat_id"`
OwnerID string `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 time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ObjectKey string `json:"-"`
ID string `json:"id"`
ChatID string `json:"chat_id"`
OwnerID string `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 time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ObjectKey string `json:"-"`
ReadyAt *time.Time `json:"-"`
Referenced bool `json:"-"`
}
type StoredObject struct {
Key string
Size int64
LastModified time.Time
}
type Variant struct {