An atproto PDS written in Go
103
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 1ccbbe2bbf0a7ade294520ba21324edc00556c90 102 lines 2.5 kB view raw
1package models 2 3import ( 4 "context" 5 "time" 6 7 "github.com/bluesky-social/indigo/atproto/crypto" 8) 9 10type Repo struct { 11 Did string `gorm:"primaryKey"` 12 CreatedAt time.Time 13 Email string `gorm:"uniqueIndex"` 14 EmailConfirmedAt *time.Time 15 EmailVerificationCode *string 16 EmailVerificationCodeExpiresAt *time.Time 17 EmailUpdateCode *string 18 EmailUpdateCodeExpiresAt *time.Time 19 PasswordResetCode *string 20 PasswordResetCodeExpiresAt *time.Time 21 Password string 22 SigningKey []byte 23 Rev string 24 Root []byte 25 Preferences []byte 26} 27 28func (r *Repo) SignFor(ctx context.Context, did string, msg []byte) ([]byte, error) { 29 k, err := crypto.ParsePrivateBytesK256(r.SigningKey) 30 if err != nil { 31 return nil, err 32 } 33 34 sig, err := k.HashAndSign(msg) 35 if err != nil { 36 return nil, err 37 } 38 39 return sig, nil 40} 41 42type Actor struct { 43 Did string `gorm:"primaryKey"` 44 Handle string `gorm:"uniqueIndex"` 45} 46 47type RepoActor struct { 48 Repo 49 Actor 50} 51 52type InviteCode struct { 53 Code string `gorm:"primaryKey"` 54 Did string `gorm:"index"` 55 RemainingUseCount int 56} 57 58type Token struct { 59 Token string `gorm:"primaryKey"` 60 Did string `gorm:"index"` 61 RefreshToken string `gorm:"index"` 62 CreatedAt time.Time 63 ExpiresAt time.Time `gorm:"index:,sort:asc"` 64} 65 66type RefreshToken struct { 67 Token string `gorm:"primaryKey"` 68 Did string `gorm:"index"` 69 CreatedAt time.Time 70 ExpiresAt time.Time `gorm:"index:,sort:asc"` 71} 72 73type Record struct { 74 Did string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"` 75 CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"` 76 Nsid string `gorm:"primaryKey;index:idx_record_did_nsid"` 77 Rkey string `gorm:"primaryKey"` 78 Cid string 79 Value []byte 80} 81 82type Block struct { 83 Did string `gorm:"primaryKey;index:idx_blocks_by_rev"` 84 Cid []byte `gorm:"primaryKey"` 85 Rev string `gorm:"index:idx_blocks_by_rev,sort:desc"` 86 Value []byte 87} 88 89type Blob struct { 90 ID uint 91 CreatedAt string `gorm:"index"` 92 Did string `gorm:"index;index:idx_blob_did_cid"` 93 Cid []byte `gorm:"index;index:idx_blob_did_cid"` 94 RefCount int 95} 96 97type BlobPart struct { 98 Blob Blob 99 BlobID uint `gorm:"primaryKey"` 100 Idx int `gorm:"primaryKey"` 101 Data []byte 102}