types.go raw
1 package database
2
3 import "time"
4
5 // Subscription represents a user's subscription status
6 type Subscription struct {
7 TrialEnd time.Time `json:"trial_end"`
8 PaidUntil time.Time `json:"paid_until"`
9 BlossomLevel string `json:"blossom_level,omitempty"` // Service level name (e.g., "basic", "premium")
10 BlossomStorage int64 `json:"blossom_storage,omitempty"` // Storage quota in MB
11 }
12
13 // Payment represents a recorded payment
14 type Payment struct {
15 Amount int64 `json:"amount"`
16 Timestamp time.Time `json:"timestamp"`
17 Invoice string `json:"invoice"`
18 Preimage string `json:"preimage"`
19 }
20
21 // NIP43Membership represents membership metadata for NIP-43
22 type NIP43Membership struct {
23 Pubkey []byte
24 AddedAt time.Time
25 InviteCode string
26 }
27
28 // WordToken represents a normalized word with its truncated hash for indexing.
29 // Used by TokenWords() for NIP-50 word search across database backends.
30 type WordToken struct {
31 Word string // normalized lowercase word (e.g., "bitcoin")
32 Hash []byte // 8-byte truncated SHA-256
33 }
34
35 // BlobMetadata stores metadata about a blob in the database
36 type BlobMetadata struct {
37 Pubkey []byte `json:"pubkey"`
38 MimeType string `json:"mime_type"`
39 Uploaded int64 `json:"uploaded"`
40 Size int64 `json:"size"`
41 Extension string `json:"extension"` // File extension (e.g., ".png", ".pdf")
42 }
43
44 // BlobDescriptor represents a blob descriptor as defined in BUD-02
45 type BlobDescriptor struct {
46 URL string `json:"url"`
47 SHA256 string `json:"sha256"`
48 Size int64 `json:"size"`
49 Type string `json:"type"`
50 Uploaded int64 `json:"uploaded"`
51 NIP94 [][]string `json:"nip94,omitempty"`
52 }
53
54 // UserBlobStats represents storage statistics for a single user
55 type UserBlobStats struct {
56 PubkeyHex string
57 BlobCount int64
58 TotalSizeBytes int64
59 }
60