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} 34 35func (r *Repo) SignFor(ctx context.Context, did string, msg []byte) ([]byte, error) { 36 k, err := atcrypto.ParsePrivateBytesK256(r.SigningKey) 37 if err != nil { 38 return nil, err 39 } 40 41 sig, err := k.HashAndSign(msg) 42 if err != nil { 43 return nil, err 44 } 45 46 return sig, nil 47} 48 49func (r *Repo) Status() *string { 50 var status *string 51 if r.Deactivated { 52 status = to.StringPtr("deactivated") 53 } 54 return status 55} 56 57func (r *Repo) Active() bool { 58 return r.Status() == nil 59} 60 61type Actor struct { 62 Did string `gorm:"primaryKey"` 63 Handle string `gorm:"uniqueIndex"` 64} 65 66type RepoActor struct { 67 Repo 68 Actor 69} 70 71type InviteCode struct { 72 Code string `gorm:"primaryKey"` 73 Did string `gorm:"index"` 74 RemainingUseCount int 75} 76 77type Token struct { 78 Token string `gorm:"primaryKey"` 79 Did string `gorm:"index"` 80 RefreshToken string `gorm:"index"` 81 CreatedAt time.Time 82 ExpiresAt time.Time `gorm:"index:,sort:asc"` 83} 84 85type RefreshToken struct { 86 Token string `gorm:"primaryKey"` 87 Did string `gorm:"index"` 88 CreatedAt time.Time 89 ExpiresAt time.Time `gorm:"index:,sort:asc"` 90} 91 92type Record struct { 93 Did string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"` 94 CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"` 95 Nsid string `gorm:"primaryKey;index:idx_record_did_nsid"` 96 Rkey string `gorm:"primaryKey"` 97 Cid string 98 Value []byte 99} 100 101type Block struct { 102 Did string `gorm:"primaryKey;index:idx_blocks_by_rev"` 103 Cid []byte `gorm:"primaryKey"` 104 Rev string `gorm:"index:idx_blocks_by_rev,sort:desc"` 105 Value []byte 106} 107 108type Blob struct { 109 ID uint 110 CreatedAt string `gorm:"index"` 111 Did string `gorm:"index;index:idx_blob_did_cid"` 112 Cid []byte `gorm:"index;index:idx_blob_did_cid"` 113 RefCount int 114 Storage string `gorm:"default:sqlite"` 115} 116 117type BlobPart struct { 118 Blob Blob 119 BlobID uint `gorm:"primaryKey"` 120 Idx int `gorm:"primaryKey"` 121 Data []byte 122} 123 124type ReservedKey struct { 125 KeyDid string `gorm:"primaryKey"` 126 Did *string `gorm:"index"` 127 PrivateKey []byte 128 CreatedAt time.Time `gorm:"index"` 129}