this repo has no description
1package models 2 3import ( 4 "context" 5 "time" 6 7 "github.com/Azure/go-autorest/autorest/to" 8 "github.com/bluesky-social/indigo/atproto/atcrypto" 9) 10 11type Repo struct { 12 Did string `gorm:"primaryKey"` 13 CreatedAt time.Time 14 Email string `gorm:"uniqueIndex"` 15 EmailConfirmedAt *time.Time 16 EmailVerificationCode *string 17 EmailVerificationCodeExpiresAt *time.Time 18 EmailUpdateCode *string 19 EmailUpdateCodeExpiresAt *time.Time 20 PasswordResetCode *string 21 PasswordResetCodeExpiresAt *time.Time 22 PlcOperationCode *string 23 PlcOperationCodeExpiresAt *time.Time 24 AccountDeleteCode *string 25 AccountDeleteCodeExpiresAt *time.Time 26 Password string 27 SigningKey []byte 28 Rev string 29 Root []byte 30 Preferences []byte 31 Deactivated bool 32 EmailAuthFactor bool 33 AuthCode *string 34 AuthCodeExpiresAt *time.Time 35} 36 37func (r *Repo) SignFor(ctx context.Context, did string, msg []byte) ([]byte, error) { 38 k, err := atcrypto.ParsePrivateBytesK256(r.SigningKey) 39 if err != nil { 40 return nil, err 41 } 42 43 sig, err := k.HashAndSign(msg) 44 if err != nil { 45 return nil, err 46 } 47 48 return sig, nil 49} 50 51func (r *Repo) Status() *string { 52 var status *string 53 if r.Deactivated { 54 status = to.StringPtr("deactivated") 55 } 56 return status 57} 58 59func (r *Repo) Active() bool { 60 return r.Status() == nil 61} 62 63type Actor struct { 64 Did string `gorm:"primaryKey"` 65 Handle string `gorm:"uniqueIndex"` 66} 67 68type RepoActor struct { 69 Repo 70 Actor 71} 72 73type InviteCode struct { 74 Code string `gorm:"primaryKey"` 75 Did string `gorm:"index"` 76 RemainingUseCount int 77} 78 79type Token struct { 80 Token string `gorm:"primaryKey"` 81 Did string `gorm:"index"` 82 RefreshToken string `gorm:"index"` 83 CreatedAt time.Time 84 ExpiresAt time.Time `gorm:"index:,sort:asc"` 85} 86 87type RefreshToken struct { 88 Token string `gorm:"primaryKey"` 89 Did string `gorm:"index"` 90 CreatedAt time.Time 91 ExpiresAt time.Time `gorm:"index:,sort:asc"` 92} 93 94type Record struct { 95 Did string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"` 96 CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"` 97 Nsid string `gorm:"primaryKey;index:idx_record_did_nsid"` 98 Rkey string `gorm:"primaryKey"` 99 Cid string 100 Value []byte 101} 102 103type Block struct { 104 Did string `gorm:"primaryKey;index:idx_blocks_by_rev"` 105 Cid []byte `gorm:"primaryKey"` 106 Rev string `gorm:"index:idx_blocks_by_rev,sort:desc"` 107 Value []byte 108} 109 110type Blob struct { 111 ID uint 112 CreatedAt string `gorm:"index"` 113 Did string `gorm:"index;index:idx_blob_did_cid"` 114 Cid []byte `gorm:"index;index:idx_blob_did_cid"` 115 RefCount int 116 Storage string `gorm:"default:sqlite"` 117} 118 119type BlobPart struct { 120 Blob Blob 121 BlobID uint `gorm:"primaryKey"` 122 Idx int `gorm:"primaryKey"` 123 Data []byte 124} 125 126type ReservedKey struct { 127 KeyDid string `gorm:"primaryKey"` 128 Did *string `gorm:"index"` 129 PrivateKey []byte 130 CreatedAt time.Time `gorm:"index"` 131}