this repo has no description
0
fork

Configure Feed

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

works well enough for the app to run against

+1502 -1534
+7 -24
api/atproto/accountcreate.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.account.create 11 10 12 - type AccountCreate_Input struct { 13 - RecoveryKey string `json:"recoveryKey" cborgen:"recoveryKey"` 14 - Email string `json:"email" cborgen:"email"` 15 - Handle string `json:"handle" cborgen:"handle"` 16 - InviteCode string `json:"inviteCode" cborgen:"inviteCode"` 17 - Password string `json:"password" cborgen:"password"` 11 + func init() { 18 12 } 19 13 20 - func (t *AccountCreate_Input) MarshalJSON() ([]byte, error) { 21 - out := make(map[string]interface{}) 22 - out["email"] = t.Email 23 - out["handle"] = t.Handle 24 - out["inviteCode"] = t.InviteCode 25 - out["password"] = t.Password 26 - out["recoveryKey"] = t.RecoveryKey 27 - return json.Marshal(out) 14 + type AccountCreate_Input struct { 15 + Email string `json:"email" cborgen:"email"` 16 + Handle string `json:"handle" cborgen:"handle"` 17 + InviteCode *string `json:"inviteCode" cborgen:"inviteCode"` 18 + Password string `json:"password" cborgen:"password"` 19 + RecoveryKey *string `json:"recoveryKey" cborgen:"recoveryKey"` 28 20 } 29 21 30 22 type AccountCreate_Output struct { ··· 32 24 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 33 25 Handle string `json:"handle" cborgen:"handle"` 34 26 Did string `json:"did" cborgen:"did"` 35 - } 36 - 37 - func (t *AccountCreate_Output) MarshalJSON() ([]byte, error) { 38 - out := make(map[string]interface{}) 39 - out["accessJwt"] = t.AccessJwt 40 - out["did"] = t.Did 41 - out["handle"] = t.Handle 42 - out["refreshJwt"] = t.RefreshJwt 43 - return json.Marshal(out) 44 27 } 45 28 46 29 func AccountCreate(ctx context.Context, c *xrpc.Client, input AccountCreate_Input) (*AccountCreate_Output, error) {
+3 -13
api/atproto/accountcreateInviteCode.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.account.createInviteCode 11 10 12 - type AccountCreateInviteCode_Input struct { 13 - UseCount int64 `json:"useCount" cborgen:"useCount"` 11 + func init() { 14 12 } 15 13 16 - func (t *AccountCreateInviteCode_Input) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["useCount"] = t.UseCount 19 - return json.Marshal(out) 14 + type AccountCreateInviteCode_Input struct { 15 + UseCount int64 `json:"useCount" cborgen:"useCount"` 20 16 } 21 17 22 18 type AccountCreateInviteCode_Output struct { 23 19 Code string `json:"code" cborgen:"code"` 24 - } 25 - 26 - func (t *AccountCreateInviteCode_Output) MarshalJSON() ([]byte, error) { 27 - out := make(map[string]interface{}) 28 - out["code"] = t.Code 29 - return json.Marshal(out) 30 20 } 31 21 32 22 func AccountCreateInviteCode(ctx context.Context, c *xrpc.Client, input AccountCreateInviteCode_Input) (*AccountCreateInviteCode_Output, error) {
+2
api/atproto/accountdelete.go
··· 8 8 9 9 // schema: com.atproto.account.delete 10 10 11 + func init() { 12 + } 11 13 func AccountDelete(ctx context.Context, c *xrpc.Client) error { 12 14 if err := c.Do(ctx, xrpc.Procedure, "", "com.atproto.account.delete", nil, nil, nil); err != nil { 13 15 return err
+2
api/atproto/accountget.go
··· 8 8 9 9 // schema: com.atproto.account.get 10 10 11 + func init() { 12 + } 11 13 func AccountGet(ctx context.Context, c *xrpc.Client) error { 12 14 if err := c.Do(ctx, xrpc.Query, "", "com.atproto.account.get", nil, nil, nil); err != nil { 13 15 return err
+3 -7
api/atproto/accountrequestPasswordReset.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.account.requestPasswordReset 11 10 12 - type AccountRequestPasswordReset_Input struct { 13 - Email string `json:"email" cborgen:"email"` 11 + func init() { 14 12 } 15 13 16 - func (t *AccountRequestPasswordReset_Input) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["email"] = t.Email 19 - return json.Marshal(out) 14 + type AccountRequestPasswordReset_Input struct { 15 + Email string `json:"email" cborgen:"email"` 20 16 } 21 17 22 18 func AccountRequestPasswordReset(ctx context.Context, c *xrpc.Client, input AccountRequestPasswordReset_Input) error {
+3 -8
api/atproto/accountresetPassword.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.account.resetPassword 11 10 11 + func init() { 12 + } 13 + 12 14 type AccountResetPassword_Input struct { 13 15 Token string `json:"token" cborgen:"token"` 14 16 Password string `json:"password" cborgen:"password"` 15 - } 16 - 17 - func (t *AccountResetPassword_Input) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["password"] = t.Password 20 - out["token"] = t.Token 21 - return json.Marshal(out) 22 17 } 23 18 24 19 func AccountResetPassword(ctx context.Context, c *xrpc.Client, input AccountResetPassword_Input) error {
+3 -7
api/atproto/handleresolve.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.handle.resolve 11 10 12 - type HandleResolve_Output struct { 13 - Did string `json:"did" cborgen:"did"` 11 + func init() { 14 12 } 15 13 16 - func (t *HandleResolve_Output) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["did"] = t.Did 19 - return json.Marshal(out) 14 + type HandleResolve_Output struct { 15 + Did string `json:"did" cborgen:"did"` 20 16 } 21 17 22 18 func HandleResolve(ctx context.Context, c *xrpc.Client, handle string) (*HandleResolve_Output, error) {
+25 -59
api/atproto/repobatchWrite.go
··· 11 11 12 12 // schema: com.atproto.repo.batchWrite 13 13 14 + func init() { 15 + } 16 + 17 + type RepoBatchWrite_Create struct { 18 + Action string `json:"action" cborgen:"action"` 19 + Collection string `json:"collection" cborgen:"collection"` 20 + Rkey *string `json:"rkey" cborgen:"rkey"` 21 + Value any `json:"value" cborgen:"value"` 22 + } 23 + 24 + type RepoBatchWrite_Update struct { 25 + Action string `json:"action" cborgen:"action"` 26 + Collection string `json:"collection" cborgen:"collection"` 27 + Rkey string `json:"rkey" cborgen:"rkey"` 28 + Value any `json:"value" cborgen:"value"` 29 + } 30 + 31 + type RepoBatchWrite_Delete struct { 32 + Action string `json:"action" cborgen:"action"` 33 + Collection string `json:"collection" cborgen:"collection"` 34 + Rkey string `json:"rkey" cborgen:"rkey"` 35 + } 36 + 14 37 type RepoBatchWrite_Input struct { 15 - Validate bool `json:"validate" cborgen:"validate"` 38 + Validate *bool `json:"validate" cborgen:"validate"` 16 39 Writes []*RepoBatchWrite_Input_Writes_Elem `json:"writes" cborgen:"writes"` 17 40 Did string `json:"did" cborgen:"did"` 18 41 } 19 42 20 - func (t *RepoBatchWrite_Input) MarshalJSON() ([]byte, error) { 21 - out := make(map[string]interface{}) 22 - out["did"] = t.Did 23 - out["validate"] = t.Validate 24 - out["writes"] = t.Writes 25 - return json.Marshal(out) 26 - } 27 - 28 43 type RepoBatchWrite_Input_Writes_Elem struct { 29 44 RepoBatchWrite_Create *RepoBatchWrite_Create 30 45 RepoBatchWrite_Update *RepoBatchWrite_Update ··· 44 59 return nil, fmt.Errorf("cannot marshal empty enum") 45 60 } 46 61 func (t *RepoBatchWrite_Input_Writes_Elem) UnmarshalJSON(b []byte) error { 47 - typ, err := util.EnumTypeExtract(b) 62 + typ, err := util.TypeExtract(b) 48 63 if err != nil { 49 64 return err 50 65 } ··· 63 78 default: 64 79 return fmt.Errorf("closed enums must have a matching value") 65 80 } 66 - } 67 - 68 - type RepoBatchWrite_Create struct { 69 - Action string `json:"action" cborgen:"action"` 70 - Collection string `json:"collection" cborgen:"collection"` 71 - Rkey string `json:"rkey" cborgen:"rkey"` 72 - Value any `json:"value" cborgen:"value"` 73 - } 74 - 75 - func (t *RepoBatchWrite_Create) MarshalJSON() ([]byte, error) { 76 - t.Action = "create" 77 - out := make(map[string]interface{}) 78 - out["action"] = t.Action 79 - out["collection"] = t.Collection 80 - out["rkey"] = t.Rkey 81 - out["value"] = t.Value 82 - return json.Marshal(out) 83 - } 84 - 85 - type RepoBatchWrite_Update struct { 86 - Rkey string `json:"rkey" cborgen:"rkey"` 87 - Value any `json:"value" cborgen:"value"` 88 - Action string `json:"action" cborgen:"action"` 89 - Collection string `json:"collection" cborgen:"collection"` 90 - } 91 - 92 - func (t *RepoBatchWrite_Update) MarshalJSON() ([]byte, error) { 93 - t.Action = "update" 94 - out := make(map[string]interface{}) 95 - out["action"] = t.Action 96 - out["collection"] = t.Collection 97 - out["rkey"] = t.Rkey 98 - out["value"] = t.Value 99 - return json.Marshal(out) 100 - } 101 - 102 - type RepoBatchWrite_Delete struct { 103 - Action string `json:"action" cborgen:"action"` 104 - Collection string `json:"collection" cborgen:"collection"` 105 - Rkey string `json:"rkey" cborgen:"rkey"` 106 - } 107 - 108 - func (t *RepoBatchWrite_Delete) MarshalJSON() ([]byte, error) { 109 - t.Action = "delete" 110 - out := make(map[string]interface{}) 111 - out["action"] = t.Action 112 - out["collection"] = t.Collection 113 - out["rkey"] = t.Rkey 114 - return json.Marshal(out) 115 81 } 116 82 117 83 func RepoBatchWrite(ctx context.Context, c *xrpc.Client, input RepoBatchWrite_Input) error {
+5 -19
api/atproto/repocreateRecord.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.createRecord 11 10 11 + func init() { 12 + } 13 + 12 14 type RepoCreateRecord_Input struct { 15 + Validate *bool `json:"validate" cborgen:"validate"` 16 + Record any `json:"record" cborgen:"record"` 13 17 Did string `json:"did" cborgen:"did"` 14 18 Collection string `json:"collection" cborgen:"collection"` 15 - Validate bool `json:"validate" cborgen:"validate"` 16 - Record any `json:"record" cborgen:"record"` 17 - } 18 - 19 - func (t *RepoCreateRecord_Input) MarshalJSON() ([]byte, error) { 20 - out := make(map[string]interface{}) 21 - out["collection"] = t.Collection 22 - out["did"] = t.Did 23 - out["record"] = t.Record 24 - out["validate"] = t.Validate 25 - return json.Marshal(out) 26 19 } 27 20 28 21 type RepoCreateRecord_Output struct { 29 22 Uri string `json:"uri" cborgen:"uri"` 30 23 Cid string `json:"cid" cborgen:"cid"` 31 - } 32 - 33 - func (t *RepoCreateRecord_Output) MarshalJSON() ([]byte, error) { 34 - out := make(map[string]interface{}) 35 - out["cid"] = t.Cid 36 - out["uri"] = t.Uri 37 - return json.Marshal(out) 38 24 } 39 25 40 26 func RepoCreateRecord(ctx context.Context, c *xrpc.Client, input RepoCreateRecord_Input) (*RepoCreateRecord_Output, error) {
+4 -10
api/atproto/repodeleteRecord.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.deleteRecord 10 + 11 + func init() { 12 + } 11 13 12 14 type RepoDeleteRecord_Input struct { 15 + Did string `json:"did" cborgen:"did"` 13 16 Collection string `json:"collection" cborgen:"collection"` 14 17 Rkey string `json:"rkey" cborgen:"rkey"` 15 - Did string `json:"did" cborgen:"did"` 16 - } 17 - 18 - func (t *RepoDeleteRecord_Input) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["collection"] = t.Collection 21 - out["did"] = t.Did 22 - out["rkey"] = t.Rkey 23 - return json.Marshal(out) 24 18 } 25 19 26 20 func RepoDeleteRecord(ctx context.Context, c *xrpc.Client, input RepoDeleteRecord_Input) error {
+5 -13
api/atproto/repodescribe.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.describe 11 10 11 + func init() { 12 + } 13 + 12 14 type RepoDescribe_Output struct { 13 - Handle string `json:"handle" cborgen:"handle"` 14 - Did string `json:"did" cborgen:"did"` 15 15 DidDoc any `json:"didDoc" cborgen:"didDoc"` 16 16 Collections []string `json:"collections" cborgen:"collections"` 17 17 HandleIsCorrect bool `json:"handleIsCorrect" cborgen:"handleIsCorrect"` 18 - } 19 - 20 - func (t *RepoDescribe_Output) MarshalJSON() ([]byte, error) { 21 - out := make(map[string]interface{}) 22 - out["collections"] = t.Collections 23 - out["did"] = t.Did 24 - out["didDoc"] = t.DidDoc 25 - out["handle"] = t.Handle 26 - out["handleIsCorrect"] = t.HandleIsCorrect 27 - return json.Marshal(out) 18 + Handle string `json:"handle" cborgen:"handle"` 19 + Did string `json:"did" cborgen:"did"` 28 20 } 29 21 30 22 func RepoDescribe(ctx context.Context, c *xrpc.Client, user string) (*RepoDescribe_Output, error) {
+5 -11
api/atproto/repogetRecord.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.getRecord 11 10 12 - type RepoGetRecord_Output struct { 13 - Value any `json:"value" cborgen:"value"` 14 - Uri string `json:"uri" cborgen:"uri"` 15 - Cid string `json:"cid" cborgen:"cid"` 11 + func init() { 16 12 } 17 13 18 - func (t *RepoGetRecord_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["cid"] = t.Cid 21 - out["uri"] = t.Uri 22 - out["value"] = t.Value 23 - return json.Marshal(out) 14 + type RepoGetRecord_Output struct { 15 + Uri string `json:"uri" cborgen:"uri"` 16 + Cid *string `json:"cid" cborgen:"cid"` 17 + Value any `json:"value" cborgen:"value"` 24 18 } 25 19 26 20 func RepoGetRecord(ctx context.Context, c *xrpc.Client, cid string, collection string, rkey string, user string) (*RepoGetRecord_Output, error) {
+5 -18
api/atproto/repolistRecords.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.listRecords 11 10 11 + func init() { 12 + } 13 + 12 14 type RepoListRecords_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 14 16 Records []*RepoListRecords_Record `json:"records" cborgen:"records"` 15 17 } 16 18 17 - func (t *RepoListRecords_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["cursor"] = t.Cursor 20 - out["records"] = t.Records 21 - return json.Marshal(out) 22 - } 23 - 24 19 type RepoListRecords_Record struct { 25 - Value any `json:"value" cborgen:"value"` 26 20 Uri string `json:"uri" cborgen:"uri"` 27 21 Cid string `json:"cid" cborgen:"cid"` 28 - } 29 - 30 - func (t *RepoListRecords_Record) MarshalJSON() ([]byte, error) { 31 - out := make(map[string]interface{}) 32 - out["cid"] = t.Cid 33 - out["uri"] = t.Uri 34 - out["value"] = t.Value 35 - return json.Marshal(out) 22 + Value any `json:"value" cborgen:"value"` 36 23 } 37 24 38 25 func RepoListRecords(ctx context.Context, c *xrpc.Client, after string, before string, collection string, limit int64, reverse bool, user string) (*RepoListRecords_Output, error) {
+6 -21
api/atproto/repoputRecord.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.repo.putRecord 11 10 11 + func init() { 12 + } 13 + 12 14 type RepoPutRecord_Input struct { 13 - Rkey string `json:"rkey" cborgen:"rkey"` 14 - Validate bool `json:"validate" cborgen:"validate"` 15 - Record any `json:"record" cborgen:"record"` 16 15 Did string `json:"did" cborgen:"did"` 17 16 Collection string `json:"collection" cborgen:"collection"` 18 - } 19 - 20 - func (t *RepoPutRecord_Input) MarshalJSON() ([]byte, error) { 21 - out := make(map[string]interface{}) 22 - out["collection"] = t.Collection 23 - out["did"] = t.Did 24 - out["record"] = t.Record 25 - out["rkey"] = t.Rkey 26 - out["validate"] = t.Validate 27 - return json.Marshal(out) 17 + Rkey string `json:"rkey" cborgen:"rkey"` 18 + Validate *bool `json:"validate" cborgen:"validate"` 19 + Record any `json:"record" cborgen:"record"` 28 20 } 29 21 30 22 type RepoPutRecord_Output struct { 31 23 Uri string `json:"uri" cborgen:"uri"` 32 24 Cid string `json:"cid" cborgen:"cid"` 33 - } 34 - 35 - func (t *RepoPutRecord_Output) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["cid"] = t.Cid 38 - out["uri"] = t.Uri 39 - return json.Marshal(out) 40 25 } 41 26 42 27 func RepoPutRecord(ctx context.Context, c *xrpc.Client, input RepoPutRecord_Input) (*RepoPutRecord_Output, error) {
+4 -12
api/atproto/repostrongRef.go
··· 1 1 package schemagen 2 2 3 - import ( 4 - "encoding/json" 5 - ) 6 - 7 3 // schema: com.atproto.repo.strongRef 8 4 9 - type RepoStrongRef struct { 10 - Uri string `json:"uri" cborgen:"uri"` 11 - Cid string `json:"cid" cborgen:"cid"` 5 + func init() { 12 6 } 13 7 14 - func (t *RepoStrongRef) MarshalJSON() ([]byte, error) { 15 - out := make(map[string]interface{}) 16 - out["cid"] = t.Cid 17 - out["uri"] = t.Uri 18 - return json.Marshal(out) 8 + type RepoStrongRef struct { 9 + Cid string `json:"cid" cborgen:"cid"` 10 + Uri string `json:"uri" cborgen:"uri"` 19 11 }
+4 -23
api/atproto/servergetAccountsConfig.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.server.getAccountsConfig 11 10 12 - type ServerGetAccountsConfig_Output struct { 13 - InviteCodeRequired bool `json:"inviteCodeRequired" cborgen:"inviteCodeRequired"` 14 - AvailableUserDomains []string `json:"availableUserDomains" cborgen:"availableUserDomains"` 15 - Links *ServerGetAccountsConfig_Links `json:"links" cborgen:"links"` 11 + func init() { 16 12 } 17 13 18 - func (t *ServerGetAccountsConfig_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["availableUserDomains"] = t.AvailableUserDomains 21 - out["inviteCodeRequired"] = t.InviteCodeRequired 22 - out["links"] = t.Links 23 - return json.Marshal(out) 24 - } 25 - 26 - type ServerGetAccountsConfig_Links struct { 27 - PrivacyPolicy string `json:"privacyPolicy" cborgen:"privacyPolicy"` 28 - TermsOfService string `json:"termsOfService" cborgen:"termsOfService"` 29 - } 30 - 31 - func (t *ServerGetAccountsConfig_Links) MarshalJSON() ([]byte, error) { 32 - out := make(map[string]interface{}) 33 - out["privacyPolicy"] = t.PrivacyPolicy 34 - out["termsOfService"] = t.TermsOfService 35 - return json.Marshal(out) 14 + type ServerGetAccountsConfig_Output struct { 15 + InviteCodeRequired *bool `json:"inviteCodeRequired" cborgen:"inviteCodeRequired"` 16 + AvailableUserDomains []string `json:"availableUserDomains" cborgen:"availableUserDomains"` 36 17 } 37 18 38 19 func ServerGetAccountsConfig(ctx context.Context, c *xrpc.Client) (*ServerGetAccountsConfig_Output, error) {
+4 -18
api/atproto/sessioncreate.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.session.create 11 10 11 + func init() { 12 + } 13 + 12 14 type SessionCreate_Input struct { 13 15 Handle string `json:"handle" cborgen:"handle"` 14 16 Password string `json:"password" cborgen:"password"` 15 - } 16 - 17 - func (t *SessionCreate_Input) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["handle"] = t.Handle 20 - out["password"] = t.Password 21 - return json.Marshal(out) 22 17 } 23 18 24 19 type SessionCreate_Output struct { 20 + Did string `json:"did" cborgen:"did"` 25 21 AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 26 22 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 27 23 Handle string `json:"handle" cborgen:"handle"` 28 - Did string `json:"did" cborgen:"did"` 29 - } 30 - 31 - func (t *SessionCreate_Output) MarshalJSON() ([]byte, error) { 32 - out := make(map[string]interface{}) 33 - out["accessJwt"] = t.AccessJwt 34 - out["did"] = t.Did 35 - out["handle"] = t.Handle 36 - out["refreshJwt"] = t.RefreshJwt 37 - return json.Marshal(out) 38 24 } 39 25 40 26 func SessionCreate(ctx context.Context, c *xrpc.Client, input SessionCreate_Input) (*SessionCreate_Output, error) {
+2
api/atproto/sessiondelete.go
··· 8 8 9 9 // schema: com.atproto.session.delete 10 10 11 + func init() { 12 + } 11 13 func SessionDelete(ctx context.Context, c *xrpc.Client) error { 12 14 if err := c.Do(ctx, xrpc.Procedure, "", "com.atproto.session.delete", nil, nil, nil); err != nil { 13 15 return err
+3 -8
api/atproto/sessionget.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.session.get 11 10 11 + func init() { 12 + } 13 + 12 14 type SessionGet_Output struct { 13 15 Handle string `json:"handle" cborgen:"handle"` 14 16 Did string `json:"did" cborgen:"did"` 15 - } 16 - 17 - func (t *SessionGet_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["did"] = t.Did 20 - out["handle"] = t.Handle 21 - return json.Marshal(out) 22 17 } 23 18 24 19 func SessionGet(ctx context.Context, c *xrpc.Client) (*SessionGet_Output, error) {
+4 -11
api/atproto/sessionrefresh.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.session.refresh 10 + 11 + func init() { 12 + } 11 13 12 14 type SessionRefresh_Output struct { 13 - Did string `json:"did" cborgen:"did"` 14 15 AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 15 16 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 16 17 Handle string `json:"handle" cborgen:"handle"` 17 - } 18 - 19 - func (t *SessionRefresh_Output) MarshalJSON() ([]byte, error) { 20 - out := make(map[string]interface{}) 21 - out["accessJwt"] = t.AccessJwt 22 - out["did"] = t.Did 23 - out["handle"] = t.Handle 24 - out["refreshJwt"] = t.RefreshJwt 25 - return json.Marshal(out) 18 + Did string `json:"did" cborgen:"did"` 26 19 } 27 20 28 21 func SessionRefresh(ctx context.Context, c *xrpc.Client) (*SessionRefresh_Output, error) {
+2
api/atproto/syncgetRepo.go
··· 9 9 10 10 // schema: com.atproto.sync.getRepo 11 11 12 + func init() { 13 + } 12 14 func SyncGetRepo(ctx context.Context, c *xrpc.Client, did string, from string) ([]byte, error) { 13 15 buf := new(bytes.Buffer) 14 16
+3 -7
api/atproto/syncgetRoot.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: com.atproto.sync.getRoot 11 10 12 - type SyncGetRoot_Output struct { 13 - Root string `json:"root" cborgen:"root"` 11 + func init() { 14 12 } 15 13 16 - func (t *SyncGetRoot_Output) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["root"] = t.Root 19 - return json.Marshal(out) 14 + type SyncGetRoot_Output struct { 15 + Root string `json:"root" cborgen:"root"` 20 16 } 21 17 22 18 func SyncGetRoot(ctx context.Context, c *xrpc.Client, did string) (*SyncGetRoot_Output, error) {
+2
api/atproto/syncupdateRepo.go
··· 9 9 10 10 // schema: com.atproto.sync.updateRepo 11 11 12 + func init() { 13 + } 12 14 func SyncUpdateRepo(ctx context.Context, c *xrpc.Client, input io.Reader, did string) error { 13 15 14 16 params := map[string]interface{}{
+4 -17
api/bsky/actorcreateScene.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.createScene 11 10 12 - type ActorCreateScene_Input struct { 13 - Handle string `json:"handle" cborgen:"handle"` 14 - RecoveryKey string `json:"recoveryKey" cborgen:"recoveryKey"` 11 + func init() { 15 12 } 16 13 17 - func (t *ActorCreateScene_Input) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["handle"] = t.Handle 20 - out["recoveryKey"] = t.RecoveryKey 21 - return json.Marshal(out) 14 + type ActorCreateScene_Input struct { 15 + Handle string `json:"handle" cborgen:"handle"` 16 + RecoveryKey *string `json:"recoveryKey" cborgen:"recoveryKey"` 22 17 } 23 18 24 19 type ActorCreateScene_Output struct { 25 20 Handle string `json:"handle" cborgen:"handle"` 26 21 Did string `json:"did" cborgen:"did"` 27 22 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 28 - } 29 - 30 - func (t *ActorCreateScene_Output) MarshalJSON() ([]byte, error) { 31 - out := make(map[string]interface{}) 32 - out["declaration"] = t.Declaration 33 - out["did"] = t.Did 34 - out["handle"] = t.Handle 35 - return json.Marshal(out) 36 23 } 37 24 38 25 func ActorCreateScene(ctx context.Context, c *xrpc.Client, input ActorCreateScene_Input) (*ActorCreateScene_Output, error) {
+9 -30
api/bsky/actorgetProfile.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.getProfile 11 10 11 + func init() { 12 + } 13 + 12 14 type ActorGetProfile_Output struct { 13 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 14 - Creator string `json:"creator" cborgen:"creator"` 15 - DisplayName string `json:"displayName" cborgen:"displayName"` 15 + Description *string `json:"description" cborgen:"description"` 16 16 FollowersCount int64 `json:"followersCount" cborgen:"followersCount"` 17 - FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 18 17 MembersCount int64 `json:"membersCount" cborgen:"membersCount"` 19 18 PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 20 - MyState *ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 21 19 Did string `json:"did" cborgen:"did"` 20 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 22 21 Handle string `json:"handle" cborgen:"handle"` 23 - Description string `json:"description" cborgen:"description"` 24 - } 25 - 26 - func (t *ActorGetProfile_Output) MarshalJSON() ([]byte, error) { 27 - out := make(map[string]interface{}) 28 - out["creator"] = t.Creator 29 - out["declaration"] = t.Declaration 30 - out["description"] = t.Description 31 - out["did"] = t.Did 32 - out["displayName"] = t.DisplayName 33 - out["followersCount"] = t.FollowersCount 34 - out["followsCount"] = t.FollowsCount 35 - out["handle"] = t.Handle 36 - out["membersCount"] = t.MembersCount 37 - out["myState"] = t.MyState 38 - out["postsCount"] = t.PostsCount 39 - return json.Marshal(out) 22 + MyState *ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 23 + Creator string `json:"creator" cborgen:"creator"` 24 + DisplayName *string `json:"displayName" cborgen:"displayName"` 25 + FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 40 26 } 41 27 42 28 type ActorGetProfile_MyState struct { 43 29 Follow string `json:"follow" cborgen:"follow"` 44 30 Member string `json:"member" cborgen:"member"` 45 - } 46 - 47 - func (t *ActorGetProfile_MyState) MarshalJSON() ([]byte, error) { 48 - out := make(map[string]interface{}) 49 - out["follow"] = t.Follow 50 - out["member"] = t.Member 51 - return json.Marshal(out) 52 31 } 53 32 54 33 func ActorGetProfile(ctx context.Context, c *xrpc.Client, actor string) (*ActorGetProfile_Output, error) {
+9 -32
api/bsky/actorgetSuggestions.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.getSuggestions 11 10 12 - type ActorGetSuggestions_MyState struct { 13 - Follow string `json:"follow" cborgen:"follow"` 14 - } 15 - 16 - func (t *ActorGetSuggestions_MyState) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["follow"] = t.Follow 19 - return json.Marshal(out) 11 + func init() { 20 12 } 21 13 22 14 type ActorGetSuggestions_Output struct { 23 - Cursor string `json:"cursor" cborgen:"cursor"` 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 24 16 Actors []*ActorGetSuggestions_Actor `json:"actors" cborgen:"actors"` 25 17 } 26 18 27 - func (t *ActorGetSuggestions_Output) MarshalJSON() ([]byte, error) { 28 - out := make(map[string]interface{}) 29 - out["actors"] = t.Actors 30 - out["cursor"] = t.Cursor 31 - return json.Marshal(out) 32 - } 33 - 34 19 type ActorGetSuggestions_Actor struct { 20 + MyState *ActorGetSuggestions_MyState `json:"myState" cborgen:"myState"` 21 + Did string `json:"did" cborgen:"did"` 35 22 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 36 23 Handle string `json:"handle" cborgen:"handle"` 37 - DisplayName string `json:"displayName" cborgen:"displayName"` 38 - Description string `json:"description" cborgen:"description"` 39 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 40 - MyState *ActorGetSuggestions_MyState `json:"myState" cborgen:"myState"` 41 - Did string `json:"did" cborgen:"did"` 24 + DisplayName *string `json:"displayName" cborgen:"displayName"` 25 + Description *string `json:"description" cborgen:"description"` 26 + IndexedAt *string `json:"indexedAt" cborgen:"indexedAt"` 42 27 } 43 28 44 - func (t *ActorGetSuggestions_Actor) MarshalJSON() ([]byte, error) { 45 - out := make(map[string]interface{}) 46 - out["declaration"] = t.Declaration 47 - out["description"] = t.Description 48 - out["did"] = t.Did 49 - out["displayName"] = t.DisplayName 50 - out["handle"] = t.Handle 51 - out["indexedAt"] = t.IndexedAt 52 - out["myState"] = t.MyState 53 - return json.Marshal(out) 29 + type ActorGetSuggestions_MyState struct { 30 + Follow string `json:"follow" cborgen:"follow"` 54 31 } 55 32 56 33 func ActorGetSuggestions(ctx context.Context, c *xrpc.Client, cursor string, limit int64) (*ActorGetSuggestions_Output, error) {
+8 -10
api/bsky/actorprofile.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 4 + "github.com/whyrusleeping/gosky/lex/util" 5 5 ) 6 6 7 7 // schema: app.bsky.actor.profile 8 8 9 - // RECORDTYPE: ActorProfile 10 - type ActorProfile struct { 11 - DisplayName string `json:"displayName" cborgen:"displayName"` 12 - Description string `json:"description" cborgen:"description"` 9 + func init() { 10 + util.RegisterType("app.bsky.actor.profile", ActorProfile{}) 13 11 } 14 12 15 - func (t *ActorProfile) MarshalJSON() ([]byte, error) { 16 - out := make(map[string]interface{}) 17 - out["description"] = t.Description 18 - out["displayName"] = t.DisplayName 19 - return json.Marshal(out) 13 + // RECORDTYPE: ActorProfile 14 + type ActorProfile struct { 15 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.actor.profile"` 16 + DisplayName string `json:"displayName" cborgen:"displayName"` 17 + Description *string `json:"description" cborgen:"description"` 20 18 }
+4 -21
api/bsky/actorref.go
··· 1 1 package schemagen 2 2 3 - import ( 4 - "encoding/json" 5 - ) 3 + // schema: app.bsky.actor.ref 6 4 7 - // schema: app.bsky.actor.ref 5 + func init() { 6 + } 8 7 9 8 type ActorRef struct { 10 9 Did string `json:"did" cborgen:"did"` 11 10 DeclarationCid string `json:"declarationCid" cborgen:"declarationCid"` 12 11 } 13 12 14 - func (t *ActorRef) MarshalJSON() ([]byte, error) { 15 - out := make(map[string]interface{}) 16 - out["declarationCid"] = t.DeclarationCid 17 - out["did"] = t.Did 18 - return json.Marshal(out) 19 - } 20 - 21 13 type ActorRef_WithInfo struct { 22 14 Did string `json:"did" cborgen:"did"` 23 15 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 24 16 Handle string `json:"handle" cborgen:"handle"` 25 - DisplayName string `json:"displayName" cborgen:"displayName"` 26 - } 27 - 28 - func (t *ActorRef_WithInfo) MarshalJSON() ([]byte, error) { 29 - out := make(map[string]interface{}) 30 - out["declaration"] = t.Declaration 31 - out["did"] = t.Did 32 - out["displayName"] = t.DisplayName 33 - out["handle"] = t.Handle 34 - return json.Marshal(out) 17 + DisplayName *string `json:"displayName" cborgen:"displayName"` 35 18 }
+7 -23
api/bsky/actorsearch.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.search 10 + 11 + func init() { 12 + } 11 13 12 14 type ActorSearch_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 14 16 Users []*ActorSearch_User `json:"users" cborgen:"users"` 15 17 } 16 18 17 - func (t *ActorSearch_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["cursor"] = t.Cursor 20 - out["users"] = t.Users 21 - return json.Marshal(out) 22 - } 23 - 24 19 type ActorSearch_User struct { 20 + DisplayName *string `json:"displayName" cborgen:"displayName"` 21 + Description *string `json:"description" cborgen:"description"` 22 + IndexedAt *string `json:"indexedAt" cborgen:"indexedAt"` 25 23 Did string `json:"did" cborgen:"did"` 26 24 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 27 25 Handle string `json:"handle" cborgen:"handle"` 28 - DisplayName string `json:"displayName" cborgen:"displayName"` 29 - Description string `json:"description" cborgen:"description"` 30 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 31 - } 32 - 33 - func (t *ActorSearch_User) MarshalJSON() ([]byte, error) { 34 - out := make(map[string]interface{}) 35 - out["declaration"] = t.Declaration 36 - out["description"] = t.Description 37 - out["did"] = t.Did 38 - out["displayName"] = t.DisplayName 39 - out["handle"] = t.Handle 40 - out["indexedAt"] = t.IndexedAt 41 - return json.Marshal(out) 42 26 } 43 27 44 28 func ActorSearch(ctx context.Context, c *xrpc.Client, before string, limit int64, term string) (*ActorSearch_Output, error) {
+4 -17
api/bsky/actorsearchTypeahead.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.searchTypeahead 11 10 11 + func init() { 12 + } 13 + 12 14 type ActorSearchTypeahead_Output struct { 13 15 Users []*ActorSearchTypeahead_User `json:"users" cborgen:"users"` 14 16 } 15 17 16 - func (t *ActorSearchTypeahead_Output) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["users"] = t.Users 19 - return json.Marshal(out) 20 - } 21 - 22 18 type ActorSearchTypeahead_User struct { 23 19 Did string `json:"did" cborgen:"did"` 24 20 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 25 21 Handle string `json:"handle" cborgen:"handle"` 26 - DisplayName string `json:"displayName" cborgen:"displayName"` 27 - } 28 - 29 - func (t *ActorSearchTypeahead_User) MarshalJSON() ([]byte, error) { 30 - out := make(map[string]interface{}) 31 - out["declaration"] = t.Declaration 32 - out["did"] = t.Did 33 - out["displayName"] = t.DisplayName 34 - out["handle"] = t.Handle 35 - return json.Marshal(out) 22 + DisplayName *string `json:"displayName" cborgen:"displayName"` 36 23 } 37 24 38 25 func ActorSearchTypeahead(ctx context.Context, c *xrpc.Client, limit int64, term string) (*ActorSearchTypeahead_Output, error) {
+4 -18
api/bsky/actorupdateProfile.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.actor.updateProfile 11 10 11 + func init() { 12 + } 13 + 12 14 type ActorUpdateProfile_Input struct { 13 - Did string `json:"did" cborgen:"did"` 14 15 DisplayName string `json:"displayName" cborgen:"displayName"` 15 16 Description string `json:"description" cborgen:"description"` 16 - } 17 - 18 - func (t *ActorUpdateProfile_Input) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["description"] = t.Description 21 - out["did"] = t.Did 22 - out["displayName"] = t.DisplayName 23 - return json.Marshal(out) 17 + Did string `json:"did" cborgen:"did"` 24 18 } 25 19 26 20 type ActorUpdateProfile_Output struct { 27 21 Uri string `json:"uri" cborgen:"uri"` 28 22 Cid string `json:"cid" cborgen:"cid"` 29 23 Record any `json:"record" cborgen:"record"` 30 - } 31 - 32 - func (t *ActorUpdateProfile_Output) MarshalJSON() ([]byte, error) { 33 - out := make(map[string]interface{}) 34 - out["cid"] = t.Cid 35 - out["record"] = t.Record 36 - out["uri"] = t.Uri 37 - return json.Marshal(out) 38 24 } 39 25 40 26 func ActorUpdateProfile(ctx context.Context, c *xrpc.Client, input ActorUpdateProfile_Input) (*ActorUpdateProfile_Output, error) {
+203 -83
api/bsky/cbor_gen.go
··· 27 27 28 28 cw := cbg.NewCborWriter(w) 29 29 30 - if _, err := cw.Write([]byte{164}); err != nil { 30 + if _, err := cw.Write([]byte{165}); err != nil { 31 + return err 32 + } 33 + 34 + // t.LexiconTypeID (string) (string) 35 + if len("$type") > cbg.MaxLength { 36 + return xerrors.Errorf("Value in field \"$type\" was too long") 37 + } 38 + 39 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 40 + return err 41 + } 42 + if _, err := io.WriteString(w, string("$type")); err != nil { 43 + return err 44 + } 45 + 46 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.LexiconTypeID))); err != nil { 47 + return err 48 + } 49 + if _, err := io.WriteString(w, string("app.bsky.feed.post")); err != nil { 31 50 return err 32 51 } 33 52 ··· 158 177 } 159 178 160 179 switch name { 161 - // t.Text (string) (string) 180 + // t.LexiconTypeID (string) (string) 181 + case "$type": 182 + 183 + { 184 + sval, err := cbg.ReadString(cr) 185 + if err != nil { 186 + return err 187 + } 188 + 189 + t.LexiconTypeID = string(sval) 190 + } 191 + // t.Text (string) (string) 162 192 case "text": 163 193 164 194 { ··· 247 277 248 278 cw := cbg.NewCborWriter(w) 249 279 250 - if _, err := cw.Write([]byte{162}); err != nil { 280 + if _, err := cw.Write([]byte{163}); err != nil { 281 + return err 282 + } 283 + 284 + // t.LexiconTypeID (string) (string) 285 + if len("$type") > cbg.MaxLength { 286 + return xerrors.Errorf("Value in field \"$type\" was too long") 287 + } 288 + 289 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 290 + return err 291 + } 292 + if _, err := io.WriteString(w, string("$type")); err != nil { 293 + return err 294 + } 295 + 296 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.LexiconTypeID))); err != nil { 297 + return err 298 + } 299 + if _, err := io.WriteString(w, string("app.bsky.feed.repost")); err != nil { 251 300 return err 252 301 } 253 302 ··· 330 379 } 331 380 332 381 switch name { 333 - // t.Subject (schemagen.RepoStrongRef) (struct) 382 + // t.LexiconTypeID (string) (string) 383 + case "$type": 384 + 385 + { 386 + sval, err := cbg.ReadString(cr) 387 + if err != nil { 388 + return err 389 + } 390 + 391 + t.LexiconTypeID = string(sval) 392 + } 393 + // t.Subject (schemagen.RepoStrongRef) (struct) 334 394 case "subject": 335 395 336 396 { ··· 378 438 379 439 cw := cbg.NewCborWriter(w) 380 440 381 - if _, err := cw.Write([]byte{162}); err != nil { 441 + if _, err := cw.Write([]byte{163}); err != nil { 442 + return err 443 + } 444 + 445 + // t.LexiconTypeID (string) (string) 446 + if len("$type") > cbg.MaxLength { 447 + return xerrors.Errorf("Value in field \"$type\" was too long") 448 + } 449 + 450 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 451 + return err 452 + } 453 + if _, err := io.WriteString(w, string("$type")); err != nil { 454 + return err 455 + } 456 + 457 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.LexiconTypeID))); err != nil { 458 + return err 459 + } 460 + if _, err := io.WriteString(w, string("app.bsky.feed.trend")); err != nil { 382 461 return err 383 462 } 384 463 ··· 461 540 } 462 541 463 542 switch name { 464 - // t.Subject (schemagen.RepoStrongRef) (struct) 543 + // t.LexiconTypeID (string) (string) 544 + case "$type": 545 + 546 + { 547 + sval, err := cbg.ReadString(cr) 548 + if err != nil { 549 + return err 550 + } 551 + 552 + t.LexiconTypeID = string(sval) 553 + } 554 + // t.Subject (schemagen.RepoStrongRef) (struct) 465 555 case "subject": 466 556 467 557 { ··· 509 599 510 600 cw := cbg.NewCborWriter(w) 511 601 512 - if _, err := cw.Write([]byte{163}); err != nil { 602 + if _, err := cw.Write([]byte{164}); err != nil { 513 603 return err 514 604 } 515 605 516 - // t.Subject (schemagen.RepoStrongRef) (struct) 517 - if len("subject") > cbg.MaxLength { 518 - return xerrors.Errorf("Value in field \"subject\" was too long") 606 + // t.LexiconTypeID (string) (string) 607 + if len("$type") > cbg.MaxLength { 608 + return xerrors.Errorf("Value in field \"$type\" was too long") 519 609 } 520 610 521 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 611 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 522 612 return err 523 613 } 524 - if _, err := io.WriteString(w, string("subject")); err != nil { 614 + if _, err := io.WriteString(w, string("$type")); err != nil { 525 615 return err 526 616 } 527 617 528 - if err := t.Subject.MarshalCBOR(cw); err != nil { 618 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.LexiconTypeID))); err != nil { 619 + return err 620 + } 621 + if _, err := io.WriteString(w, string("app.bsky.feed.vote")); err != nil { 529 622 return err 530 623 } 531 624 ··· 574 667 if _, err := io.WriteString(w, string(t.CreatedAt)); err != nil { 575 668 return err 576 669 } 670 + 671 + // t.Subject (schemagen.RepoStrongRef) (struct) 672 + if len("subject") > cbg.MaxLength { 673 + return xerrors.Errorf("Value in field \"subject\" was too long") 674 + } 675 + 676 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 677 + return err 678 + } 679 + if _, err := io.WriteString(w, string("subject")); err != nil { 680 + return err 681 + } 682 + 683 + if err := t.Subject.MarshalCBOR(cw); err != nil { 684 + return err 685 + } 577 686 return nil 578 687 } 579 688 ··· 615 724 } 616 725 617 726 switch name { 618 - // t.Subject (schemagen.RepoStrongRef) (struct) 619 - case "subject": 727 + // t.LexiconTypeID (string) (string) 728 + case "$type": 620 729 621 730 { 622 - 623 - b, err := cr.ReadByte() 731 + sval, err := cbg.ReadString(cr) 624 732 if err != nil { 625 733 return err 626 734 } 627 - if b != cbg.CborNull[0] { 628 - if err := cr.UnreadByte(); err != nil { 629 - return err 630 - } 631 - t.Subject = new(schemagen.RepoStrongRef) 632 - if err := t.Subject.UnmarshalCBOR(cr); err != nil { 633 - return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 634 - } 635 - } 636 735 736 + t.LexiconTypeID = string(sval) 637 737 } 638 738 // t.Direction (string) (string) 639 739 case "direction": ··· 657 757 658 758 t.CreatedAt = string(sval) 659 759 } 760 + // t.Subject (schemagen.RepoStrongRef) (struct) 761 + case "subject": 762 + 763 + { 764 + 765 + b, err := cr.ReadByte() 766 + if err != nil { 767 + return err 768 + } 769 + if b != cbg.CborNull[0] { 770 + if err := cr.UnreadByte(); err != nil { 771 + return err 772 + } 773 + t.Subject = new(schemagen.RepoStrongRef) 774 + if err := t.Subject.UnmarshalCBOR(cr); err != nil { 775 + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 776 + } 777 + } 778 + 779 + } 660 780 661 781 default: 662 782 // Field doesn't exist on this type, so ignore it ··· 678 798 return err 679 799 } 680 800 801 + // t.Value (string) (string) 802 + if len("value") > cbg.MaxLength { 803 + return xerrors.Errorf("Value in field \"value\" was too long") 804 + } 805 + 806 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 807 + return err 808 + } 809 + if _, err := io.WriteString(w, string("value")); err != nil { 810 + return err 811 + } 812 + 813 + if len(t.Value) > cbg.MaxLength { 814 + return xerrors.Errorf("Value in field t.Value was too long") 815 + } 816 + 817 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 818 + return err 819 + } 820 + if _, err := io.WriteString(w, string(t.Value)); err != nil { 821 + return err 822 + } 823 + 681 824 // t.Index (schemagen.FeedPost_TextSlice) (struct) 682 825 if len("index") > cbg.MaxLength { 683 826 return xerrors.Errorf("Value in field \"index\" was too long") ··· 716 859 if _, err := io.WriteString(w, string(t.Type)); err != nil { 717 860 return err 718 861 } 719 - 720 - // t.Value (string) (string) 721 - if len("value") > cbg.MaxLength { 722 - return xerrors.Errorf("Value in field \"value\" was too long") 723 - } 724 - 725 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil { 726 - return err 727 - } 728 - if _, err := io.WriteString(w, string("value")); err != nil { 729 - return err 730 - } 731 - 732 - if len(t.Value) > cbg.MaxLength { 733 - return xerrors.Errorf("Value in field t.Value was too long") 734 - } 735 - 736 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil { 737 - return err 738 - } 739 - if _, err := io.WriteString(w, string(t.Value)); err != nil { 740 - return err 741 - } 742 862 return nil 743 863 } 744 864 ··· 780 900 } 781 901 782 902 switch name { 783 - // t.Index (schemagen.FeedPost_TextSlice) (struct) 903 + // t.Value (string) (string) 904 + case "value": 905 + 906 + { 907 + sval, err := cbg.ReadString(cr) 908 + if err != nil { 909 + return err 910 + } 911 + 912 + t.Value = string(sval) 913 + } 914 + // t.Index (schemagen.FeedPost_TextSlice) (struct) 784 915 case "index": 785 916 786 917 { ··· 811 942 812 943 t.Type = string(sval) 813 944 } 814 - // t.Value (string) (string) 815 - case "value": 816 - 817 - { 818 - sval, err := cbg.ReadString(cr) 819 - if err != nil { 820 - return err 821 - } 822 - 823 - t.Value = string(sval) 824 - } 825 945 826 946 default: 827 947 // Field doesn't exist on this type, so ignore it ··· 843 963 return err 844 964 } 845 965 846 - // t.Parent (schemagen.RepoStrongRef) (struct) 847 - if len("parent") > cbg.MaxLength { 848 - return xerrors.Errorf("Value in field \"parent\" was too long") 966 + // t.Root (schemagen.RepoStrongRef) (struct) 967 + if len("root") > cbg.MaxLength { 968 + return xerrors.Errorf("Value in field \"root\" was too long") 849 969 } 850 970 851 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("parent"))); err != nil { 971 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("root"))); err != nil { 852 972 return err 853 973 } 854 - if _, err := io.WriteString(w, string("parent")); err != nil { 974 + if _, err := io.WriteString(w, string("root")); err != nil { 855 975 return err 856 976 } 857 977 858 - if err := t.Parent.MarshalCBOR(cw); err != nil { 978 + if err := t.Root.MarshalCBOR(cw); err != nil { 859 979 return err 860 980 } 861 981 862 - // t.Root (schemagen.RepoStrongRef) (struct) 863 - if len("root") > cbg.MaxLength { 864 - return xerrors.Errorf("Value in field \"root\" was too long") 982 + // t.Parent (schemagen.RepoStrongRef) (struct) 983 + if len("parent") > cbg.MaxLength { 984 + return xerrors.Errorf("Value in field \"parent\" was too long") 865 985 } 866 986 867 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("root"))); err != nil { 987 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("parent"))); err != nil { 868 988 return err 869 989 } 870 - if _, err := io.WriteString(w, string("root")); err != nil { 990 + if _, err := io.WriteString(w, string("parent")); err != nil { 871 991 return err 872 992 } 873 993 874 - if err := t.Root.MarshalCBOR(cw); err != nil { 994 + if err := t.Parent.MarshalCBOR(cw); err != nil { 875 995 return err 876 996 } 877 997 return nil ··· 915 1035 } 916 1036 917 1037 switch name { 918 - // t.Parent (schemagen.RepoStrongRef) (struct) 919 - case "parent": 1038 + // t.Root (schemagen.RepoStrongRef) (struct) 1039 + case "root": 920 1040 921 1041 { 922 1042 ··· 928 1048 if err := cr.UnreadByte(); err != nil { 929 1049 return err 930 1050 } 931 - t.Parent = new(schemagen.RepoStrongRef) 932 - if err := t.Parent.UnmarshalCBOR(cr); err != nil { 933 - return xerrors.Errorf("unmarshaling t.Parent pointer: %w", err) 1051 + t.Root = new(schemagen.RepoStrongRef) 1052 + if err := t.Root.UnmarshalCBOR(cr); err != nil { 1053 + return xerrors.Errorf("unmarshaling t.Root pointer: %w", err) 934 1054 } 935 1055 } 936 1056 937 1057 } 938 - // t.Root (schemagen.RepoStrongRef) (struct) 939 - case "root": 1058 + // t.Parent (schemagen.RepoStrongRef) (struct) 1059 + case "parent": 940 1060 941 1061 { 942 1062 ··· 948 1068 if err := cr.UnreadByte(); err != nil { 949 1069 return err 950 1070 } 951 - t.Root = new(schemagen.RepoStrongRef) 952 - if err := t.Root.UnmarshalCBOR(cr); err != nil { 953 - return xerrors.Errorf("unmarshaling t.Root pointer: %w", err) 1071 + t.Parent = new(schemagen.RepoStrongRef) 1072 + if err := t.Parent.UnmarshalCBOR(cr); err != nil { 1073 + return xerrors.Errorf("unmarshaling t.Parent pointer: %w", err) 954 1074 } 955 1075 } 956 1076
+9 -40
api/bsky/feedembed.go
··· 9 9 10 10 // schema: app.bsky.feed.embed 11 11 12 - type FeedEmbed_External struct { 13 - Title string `json:"title" cborgen:"title"` 14 - Description string `json:"description" cborgen:"description"` 15 - ImageUri string `json:"imageUri" cborgen:"imageUri"` 16 - Type string `json:"type" cborgen:"type"` 17 - Uri string `json:"uri" cborgen:"uri"` 18 - } 19 - 20 - func (t *FeedEmbed_External) MarshalJSON() ([]byte, error) { 21 - t.Type = "external" 22 - out := make(map[string]interface{}) 23 - out["description"] = t.Description 24 - out["imageUri"] = t.ImageUri 25 - out["title"] = t.Title 26 - out["type"] = t.Type 27 - out["uri"] = t.Uri 28 - return json.Marshal(out) 12 + func init() { 29 13 } 30 14 31 15 type FeedEmbed struct { 32 16 Items []*FeedEmbed_Items_Elem `json:"items" cborgen:"items"` 33 - } 34 - 35 - func (t *FeedEmbed) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["items"] = t.Items 38 - return json.Marshal(out) 39 17 } 40 18 41 19 type FeedEmbed_Items_Elem struct { ··· 57 35 return nil, fmt.Errorf("cannot marshal empty enum") 58 36 } 59 37 func (t *FeedEmbed_Items_Elem) UnmarshalJSON(b []byte) error { 60 - typ, err := util.EnumTypeExtract(b) 38 + typ, err := util.TypeExtract(b) 61 39 if err != nil { 62 40 return err 63 41 } ··· 79 57 } 80 58 81 59 type FeedEmbed_Media struct { 82 - Alt string `json:"alt" cborgen:"alt"` 60 + Alt *string `json:"alt" cborgen:"alt"` 83 61 Thumb *util.Blob `json:"thumb" cborgen:"thumb"` 84 62 Original *util.Blob `json:"original" cborgen:"original"` 85 63 } 86 64 87 - func (t *FeedEmbed_Media) MarshalJSON() ([]byte, error) { 88 - out := make(map[string]interface{}) 89 - out["alt"] = t.Alt 90 - out["original"] = t.Original 91 - out["thumb"] = t.Thumb 92 - return json.Marshal(out) 93 - } 94 - 95 65 type FeedEmbed_Record struct { 96 66 Type string `json:"type" cborgen:"type"` 97 67 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 98 68 Record any `json:"record" cborgen:"record"` 99 69 } 100 70 101 - func (t *FeedEmbed_Record) MarshalJSON() ([]byte, error) { 102 - t.Type = "record" 103 - out := make(map[string]interface{}) 104 - out["author"] = t.Author 105 - out["record"] = t.Record 106 - out["type"] = t.Type 107 - return json.Marshal(out) 71 + type FeedEmbed_External struct { 72 + Uri string `json:"uri" cborgen:"uri"` 73 + Title string `json:"title" cborgen:"title"` 74 + Description string `json:"description" cborgen:"description"` 75 + ImageUri string `json:"imageUri" cborgen:"imageUri"` 76 + Type string `json:"type" cborgen:"type"` 108 77 }
+12 -43
api/bsky/feedgetAuthorFeed.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.feed.getAuthorFeed 11 10 12 - type FeedGetAuthorFeed_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 14 - Feed []*FeedGetAuthorFeed_FeedItem `json:"feed" cborgen:"feed"` 11 + func init() { 15 12 } 16 13 17 - func (t *FeedGetAuthorFeed_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["cursor"] = t.Cursor 20 - out["feed"] = t.Feed 21 - return json.Marshal(out) 14 + type FeedGetAuthorFeed_Output struct { 15 + Feed []*FeedGetAuthorFeed_FeedItem `json:"feed" cborgen:"feed"` 16 + Cursor *string `json:"cursor" cborgen:"cursor"` 22 17 } 23 18 24 19 type FeedGetAuthorFeed_FeedItem struct { 25 - Uri string `json:"uri" cborgen:"uri"` 20 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 26 21 RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 22 + ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 23 + Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 24 + TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 27 25 Record any `json:"record" cborgen:"record"` 28 - ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 26 + Embed *FeedEmbed `json:"embed" cborgen:"embed"` 29 27 RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 30 28 UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 29 + Uri string `json:"uri" cborgen:"uri"` 30 + Cid string `json:"cid" cborgen:"cid"` 31 31 DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 32 32 MyState *FeedGetAuthorFeed_MyState `json:"myState" cborgen:"myState"` 33 - Cid string `json:"cid" cborgen:"cid"` 34 - Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 35 - TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 36 - Embed *FeedEmbed `json:"embed" cborgen:"embed"` 37 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 38 - } 39 - 40 - func (t *FeedGetAuthorFeed_FeedItem) MarshalJSON() ([]byte, error) { 41 - out := make(map[string]interface{}) 42 - out["author"] = t.Author 43 - out["cid"] = t.Cid 44 - out["downvoteCount"] = t.DownvoteCount 45 - out["embed"] = t.Embed 46 - out["indexedAt"] = t.IndexedAt 47 - out["myState"] = t.MyState 48 - out["record"] = t.Record 49 - out["replyCount"] = t.ReplyCount 50 - out["repostCount"] = t.RepostCount 51 - out["repostedBy"] = t.RepostedBy 52 - out["trendedBy"] = t.TrendedBy 53 - out["upvoteCount"] = t.UpvoteCount 54 - out["uri"] = t.Uri 55 - return json.Marshal(out) 56 33 } 57 34 58 35 type FeedGetAuthorFeed_MyState struct { 36 + Repost string `json:"repost" cborgen:"repost"` 59 37 Upvote string `json:"upvote" cborgen:"upvote"` 60 38 Downvote string `json:"downvote" cborgen:"downvote"` 61 - Repost string `json:"repost" cborgen:"repost"` 62 - } 63 - 64 - func (t *FeedGetAuthorFeed_MyState) MarshalJSON() ([]byte, error) { 65 - out := make(map[string]interface{}) 66 - out["downvote"] = t.Downvote 67 - out["repost"] = t.Repost 68 - out["upvote"] = t.Upvote 69 - return json.Marshal(out) 70 39 } 71 40 72 41 func FeedGetAuthorFeed(ctx context.Context, c *xrpc.Client, author string, before string, limit int64) (*FeedGetAuthorFeed_Output, error) {
+19 -56
api/bsky/feedgetPostThread.go
··· 11 11 12 12 // schema: app.bsky.feed.getPostThread 13 13 14 + func init() { 15 + } 16 + 14 17 type FeedGetPostThread_Output struct { 15 18 Thread *FeedGetPostThread_Output_Thread `json:"thread" cborgen:"thread"` 16 - } 17 - 18 - func (t *FeedGetPostThread_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["thread"] = t.Thread 21 - return json.Marshal(out) 22 19 } 23 20 24 21 type FeedGetPostThread_Output_Thread struct { ··· 36 33 return nil, fmt.Errorf("cannot marshal empty enum") 37 34 } 38 35 func (t *FeedGetPostThread_Output_Thread) UnmarshalJSON(b []byte) error { 39 - typ, err := util.EnumTypeExtract(b) 36 + typ, err := util.TypeExtract(b) 40 37 if err != nil { 41 38 return err 42 39 } ··· 55 52 } 56 53 57 54 type FeedGetPostThread_Post struct { 55 + DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 56 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 57 + Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies" cborgen:"replies"` 58 58 Uri string `json:"uri" cborgen:"uri"` 59 + Cid string `json:"cid" cborgen:"cid"` 60 + Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 61 + Record any `json:"record" cborgen:"record"` 59 62 Embed *FeedEmbed `json:"embed" cborgen:"embed"` 60 - RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 61 63 Parent *FeedGetPostThread_Post_Parent `json:"parent" cborgen:"parent"` 62 64 ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 63 - Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies" cborgen:"replies"` 65 + RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 64 66 UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 65 - DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 66 - Cid string `json:"cid" cborgen:"cid"` 67 - Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 68 - Record any `json:"record" cborgen:"record"` 69 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 70 67 MyState *FeedGetPostThread_MyState `json:"myState" cborgen:"myState"` 71 68 } 72 69 73 - func (t *FeedGetPostThread_Post) MarshalJSON() ([]byte, error) { 74 - out := make(map[string]interface{}) 75 - out["author"] = t.Author 76 - out["cid"] = t.Cid 77 - out["downvoteCount"] = t.DownvoteCount 78 - out["embed"] = t.Embed 79 - out["indexedAt"] = t.IndexedAt 80 - out["myState"] = t.MyState 81 - out["parent"] = t.Parent 82 - out["record"] = t.Record 83 - out["replies"] = t.Replies 84 - out["replyCount"] = t.ReplyCount 85 - out["repostCount"] = t.RepostCount 86 - out["upvoteCount"] = t.UpvoteCount 87 - out["uri"] = t.Uri 88 - return json.Marshal(out) 89 - } 90 - 91 - type FeedGetPostThread_Post_Replies_Elem struct { 70 + type FeedGetPostThread_Post_Parent struct { 92 71 FeedGetPostThread_Post *FeedGetPostThread_Post 93 72 FeedGetPostThread_NotFoundPost *FeedGetPostThread_NotFoundPost 94 73 } 95 74 96 - func (t *FeedGetPostThread_Post_Replies_Elem) MarshalJSON() ([]byte, error) { 75 + func (t *FeedGetPostThread_Post_Parent) MarshalJSON() ([]byte, error) { 97 76 if t.FeedGetPostThread_Post != nil { 98 77 return json.Marshal(t.FeedGetPostThread_Post) 99 78 } ··· 102 81 } 103 82 return nil, fmt.Errorf("cannot marshal empty enum") 104 83 } 105 - func (t *FeedGetPostThread_Post_Replies_Elem) UnmarshalJSON(b []byte) error { 106 - typ, err := util.EnumTypeExtract(b) 84 + func (t *FeedGetPostThread_Post_Parent) UnmarshalJSON(b []byte) error { 85 + typ, err := util.TypeExtract(b) 107 86 if err != nil { 108 87 return err 109 88 } ··· 121 100 } 122 101 } 123 102 124 - type FeedGetPostThread_Post_Parent struct { 103 + type FeedGetPostThread_Post_Replies_Elem struct { 125 104 FeedGetPostThread_Post *FeedGetPostThread_Post 126 105 FeedGetPostThread_NotFoundPost *FeedGetPostThread_NotFoundPost 127 106 } 128 107 129 - func (t *FeedGetPostThread_Post_Parent) MarshalJSON() ([]byte, error) { 108 + func (t *FeedGetPostThread_Post_Replies_Elem) MarshalJSON() ([]byte, error) { 130 109 if t.FeedGetPostThread_Post != nil { 131 110 return json.Marshal(t.FeedGetPostThread_Post) 132 111 } ··· 135 114 } 136 115 return nil, fmt.Errorf("cannot marshal empty enum") 137 116 } 138 - func (t *FeedGetPostThread_Post_Parent) UnmarshalJSON(b []byte) error { 139 - typ, err := util.EnumTypeExtract(b) 117 + func (t *FeedGetPostThread_Post_Replies_Elem) UnmarshalJSON(b []byte) error { 118 + typ, err := util.TypeExtract(b) 140 119 if err != nil { 141 120 return err 142 121 } ··· 159 138 NotFound bool `json:"notFound" cborgen:"notFound"` 160 139 } 161 140 162 - func (t *FeedGetPostThread_NotFoundPost) MarshalJSON() ([]byte, error) { 163 - t.NotFound = true 164 - out := make(map[string]interface{}) 165 - out["notFound"] = t.NotFound 166 - out["uri"] = t.Uri 167 - return json.Marshal(out) 168 - } 169 - 170 141 type FeedGetPostThread_MyState struct { 171 142 Repost string `json:"repost" cborgen:"repost"` 172 143 Upvote string `json:"upvote" cborgen:"upvote"` 173 144 Downvote string `json:"downvote" cborgen:"downvote"` 174 - } 175 - 176 - func (t *FeedGetPostThread_MyState) MarshalJSON() ([]byte, error) { 177 - out := make(map[string]interface{}) 178 - out["downvote"] = t.Downvote 179 - out["repost"] = t.Repost 180 - out["upvote"] = t.Upvote 181 - return json.Marshal(out) 182 145 } 183 146 184 147 func FeedGetPostThread(ctx context.Context, c *xrpc.Client, depth int64, uri string) (*FeedGetPostThread_Output, error) {
+9 -27
api/bsky/feedgetRepostedBy.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.feed.getRepostedBy 11 10 12 - type FeedGetRepostedBy_Output struct { 13 - Cid string `json:"cid" cborgen:"cid"` 14 - Cursor string `json:"cursor" cborgen:"cursor"` 15 - RepostedBy []*FeedGetRepostedBy_RepostedBy `json:"repostedBy" cborgen:"repostedBy"` 16 - Uri string `json:"uri" cborgen:"uri"` 11 + func init() { 17 12 } 18 13 19 - func (t *FeedGetRepostedBy_Output) MarshalJSON() ([]byte, error) { 20 - out := make(map[string]interface{}) 21 - out["cid"] = t.Cid 22 - out["cursor"] = t.Cursor 23 - out["repostedBy"] = t.RepostedBy 24 - out["uri"] = t.Uri 25 - return json.Marshal(out) 14 + type FeedGetRepostedBy_Output struct { 15 + Uri string `json:"uri" cborgen:"uri"` 16 + Cid *string `json:"cid" cborgen:"cid"` 17 + Cursor *string `json:"cursor" cborgen:"cursor"` 18 + RepostedBy []*FeedGetRepostedBy_RepostedBy `json:"repostedBy" cborgen:"repostedBy"` 26 19 } 27 20 28 21 type FeedGetRepostedBy_RepostedBy struct { 29 - DisplayName string `json:"displayName" cborgen:"displayName"` 30 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 31 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 32 22 Did string `json:"did" cborgen:"did"` 33 23 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 34 24 Handle string `json:"handle" cborgen:"handle"` 35 - } 36 - 37 - func (t *FeedGetRepostedBy_RepostedBy) MarshalJSON() ([]byte, error) { 38 - out := make(map[string]interface{}) 39 - out["createdAt"] = t.CreatedAt 40 - out["declaration"] = t.Declaration 41 - out["did"] = t.Did 42 - out["displayName"] = t.DisplayName 43 - out["handle"] = t.Handle 44 - out["indexedAt"] = t.IndexedAt 45 - return json.Marshal(out) 25 + DisplayName *string `json:"displayName" cborgen:"displayName"` 26 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 27 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 46 28 } 47 29 48 30 func FeedGetRepostedBy(ctx context.Context, c *xrpc.Client, before string, cid string, limit int64, uri string) (*FeedGetRepostedBy_Output, error) {
+17 -48
api/bsky/feedgetTimeline.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.feed.getTimeline 11 10 11 + func init() { 12 + } 13 + 14 + type FeedGetTimeline_MyState struct { 15 + Repost string `json:"repost" cborgen:"repost"` 16 + Upvote string `json:"upvote" cborgen:"upvote"` 17 + Downvote string `json:"downvote" cborgen:"downvote"` 18 + } 19 + 12 20 type FeedGetTimeline_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 21 + Cursor *string `json:"cursor" cborgen:"cursor"` 14 22 Feed []*FeedGetTimeline_FeedItem `json:"feed" cborgen:"feed"` 15 23 } 16 24 17 - func (t *FeedGetTimeline_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["cursor"] = t.Cursor 20 - out["feed"] = t.Feed 21 - return json.Marshal(out) 22 - } 23 - 24 25 type FeedGetTimeline_FeedItem struct { 25 - Cid string `json:"cid" cborgen:"cid"` 26 + ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 27 + TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 26 28 RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 27 29 Embed *FeedEmbed `json:"embed" cborgen:"embed"` 30 + Record any `json:"record" cborgen:"record"` 28 31 RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 32 + UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 29 33 DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 30 - MyState *FeedGetTimeline_MyState `json:"myState" cborgen:"myState"` 34 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 31 35 Uri string `json:"uri" cborgen:"uri"` 36 + Cid string `json:"cid" cborgen:"cid"` 32 37 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 33 - TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 34 - Record any `json:"record" cborgen:"record"` 35 - ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 36 - UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 37 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 38 - } 39 - 40 - func (t *FeedGetTimeline_FeedItem) MarshalJSON() ([]byte, error) { 41 - out := make(map[string]interface{}) 42 - out["author"] = t.Author 43 - out["cid"] = t.Cid 44 - out["downvoteCount"] = t.DownvoteCount 45 - out["embed"] = t.Embed 46 - out["indexedAt"] = t.IndexedAt 47 - out["myState"] = t.MyState 48 - out["record"] = t.Record 49 - out["replyCount"] = t.ReplyCount 50 - out["repostCount"] = t.RepostCount 51 - out["repostedBy"] = t.RepostedBy 52 - out["trendedBy"] = t.TrendedBy 53 - out["upvoteCount"] = t.UpvoteCount 54 - out["uri"] = t.Uri 55 - return json.Marshal(out) 56 - } 57 - 58 - type FeedGetTimeline_MyState struct { 59 - Repost string `json:"repost" cborgen:"repost"` 60 - Upvote string `json:"upvote" cborgen:"upvote"` 61 - Downvote string `json:"downvote" cborgen:"downvote"` 62 - } 63 - 64 - func (t *FeedGetTimeline_MyState) MarshalJSON() ([]byte, error) { 65 - out := make(map[string]interface{}) 66 - out["downvote"] = t.Downvote 67 - out["repost"] = t.Repost 68 - out["upvote"] = t.Upvote 69 - return json.Marshal(out) 38 + MyState *FeedGetTimeline_MyState `json:"myState" cborgen:"myState"` 70 39 } 71 40 72 41 func FeedGetTimeline(ctx context.Context, c *xrpc.Client, algorithm string, before string, limit int64) (*FeedGetTimeline_Output, error) {
+5 -21
api/bsky/feedgetVotes.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.feed.getVotes 10 + 11 + func init() { 12 + } 11 13 12 14 type FeedGetVotes_Output struct { 13 15 Uri string `json:"uri" cborgen:"uri"` 14 - Cid string `json:"cid" cborgen:"cid"` 15 - Cursor string `json:"cursor" cborgen:"cursor"` 16 + Cid *string `json:"cid" cborgen:"cid"` 17 + Cursor *string `json:"cursor" cborgen:"cursor"` 16 18 Votes []*FeedGetVotes_Vote `json:"votes" cborgen:"votes"` 17 19 } 18 20 19 - func (t *FeedGetVotes_Output) MarshalJSON() ([]byte, error) { 20 - out := make(map[string]interface{}) 21 - out["cid"] = t.Cid 22 - out["cursor"] = t.Cursor 23 - out["uri"] = t.Uri 24 - out["votes"] = t.Votes 25 - return json.Marshal(out) 26 - } 27 - 28 21 type FeedGetVotes_Vote struct { 29 22 Direction string `json:"direction" cborgen:"direction"` 30 23 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 31 24 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 32 25 Actor *ActorRef_WithInfo `json:"actor" cborgen:"actor"` 33 - } 34 - 35 - func (t *FeedGetVotes_Vote) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["actor"] = t.Actor 38 - out["createdAt"] = t.CreatedAt 39 - out["direction"] = t.Direction 40 - out["indexedAt"] = t.IndexedAt 41 - return json.Marshal(out) 42 26 } 43 27 44 28 func FeedGetVotes(ctx context.Context, c *xrpc.Client, before string, cid string, direction string, limit int64, uri string) (*FeedGetVotes_Output, error) {
+18 -45
api/bsky/feedpost.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 5 - 6 4 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 5 + "github.com/whyrusleeping/gosky/lex/util" 7 6 ) 8 7 9 8 // schema: app.bsky.feed.post 10 9 11 - type FeedPost_Entity struct { 12 - Index *FeedPost_TextSlice `json:"index" cborgen:"index"` 13 - Type string `json:"type" cborgen:"type"` 14 - Value string `json:"value" cborgen:"value"` 15 - } 16 - 17 - func (t *FeedPost_Entity) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["index"] = t.Index 20 - out["type"] = t.Type 21 - out["value"] = t.Value 22 - return json.Marshal(out) 23 - } 24 - 25 - type FeedPost_TextSlice struct { 26 - Start int64 `json:"start" cborgen:"start"` 27 - End int64 `json:"end" cborgen:"end"` 28 - } 29 - 30 - func (t *FeedPost_TextSlice) MarshalJSON() ([]byte, error) { 31 - out := make(map[string]interface{}) 32 - out["end"] = t.End 33 - out["start"] = t.Start 34 - return json.Marshal(out) 10 + func init() { 11 + util.RegisterType("app.bsky.feed.post", FeedPost{}) 35 12 } 36 13 37 14 // RECORDTYPE: FeedPost 38 15 type FeedPost struct { 39 - Text string `json:"text" cborgen:"text"` 40 - Entities []*FeedPost_Entity `json:"entities" cborgen:"entities"` 41 - Reply *FeedPost_ReplyRef `json:"reply" cborgen:"reply"` 42 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 16 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.post"` 17 + Text string `json:"text" cborgen:"text"` 18 + Entities []*FeedPost_Entity `json:"entities" cborgen:"entities"` 19 + Reply *FeedPost_ReplyRef `json:"reply" cborgen:"reply"` 20 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 43 21 } 44 22 45 - func (t *FeedPost) MarshalJSON() ([]byte, error) { 46 - out := make(map[string]interface{}) 47 - out["createdAt"] = t.CreatedAt 48 - out["entities"] = t.Entities 49 - out["reply"] = t.Reply 50 - out["text"] = t.Text 51 - return json.Marshal(out) 23 + type FeedPost_ReplyRef struct { 24 + Root *comatprototypes.RepoStrongRef `json:"root" cborgen:"root"` 25 + Parent *comatprototypes.RepoStrongRef `json:"parent" cborgen:"parent"` 52 26 } 53 27 54 - type FeedPost_ReplyRef struct { 55 - Parent *comatprototypes.RepoStrongRef `json:"parent" cborgen:"parent"` 56 - Root *comatprototypes.RepoStrongRef `json:"root" cborgen:"root"` 28 + type FeedPost_Entity struct { 29 + Index *FeedPost_TextSlice `json:"index" cborgen:"index"` 30 + Type string `json:"type" cborgen:"type"` 31 + Value string `json:"value" cborgen:"value"` 57 32 } 58 33 59 - func (t *FeedPost_ReplyRef) MarshalJSON() ([]byte, error) { 60 - out := make(map[string]interface{}) 61 - out["parent"] = t.Parent 62 - out["root"] = t.Root 63 - return json.Marshal(out) 34 + type FeedPost_TextSlice struct { 35 + End int64 `json:"end" cborgen:"end"` 36 + Start int64 `json:"start" cborgen:"start"` 64 37 }
+8 -11
api/bsky/feedrepost.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 5 - 6 4 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 5 + "github.com/whyrusleeping/gosky/lex/util" 7 6 ) 8 7 9 8 // schema: app.bsky.feed.repost 10 9 10 + func init() { 11 + util.RegisterType("app.bsky.feed.repost", FeedRepost{}) 12 + } 13 + 11 14 // RECORDTYPE: FeedRepost 12 15 type FeedRepost struct { 13 - Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 15 - } 16 - 17 - func (t *FeedRepost) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["createdAt"] = t.CreatedAt 20 - out["subject"] = t.Subject 21 - return json.Marshal(out) 16 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.repost"` 17 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 18 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 22 19 }
+3 -15
api/bsky/feedsetVote.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 8 7 "github.com/whyrusleeping/gosky/xrpc" ··· 10 9 11 10 // schema: app.bsky.feed.setVote 12 11 12 + func init() { 13 + } 14 + 13 15 type FeedSetVote_Input struct { 14 16 Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 15 17 Direction string `json:"direction" cborgen:"direction"` 16 18 } 17 19 18 - func (t *FeedSetVote_Input) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["direction"] = t.Direction 21 - out["subject"] = t.Subject 22 - return json.Marshal(out) 23 - } 24 - 25 20 type FeedSetVote_Output struct { 26 21 Upvote string `json:"upvote" cborgen:"upvote"` 27 22 Downvote string `json:"downvote" cborgen:"downvote"` 28 - } 29 - 30 - func (t *FeedSetVote_Output) MarshalJSON() ([]byte, error) { 31 - out := make(map[string]interface{}) 32 - out["downvote"] = t.Downvote 33 - out["upvote"] = t.Upvote 34 - return json.Marshal(out) 35 23 } 36 24 37 25 func FeedSetVote(ctx context.Context, c *xrpc.Client, input FeedSetVote_Input) (*FeedSetVote_Output, error) {
+8 -11
api/bsky/feedtrend.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 5 - 6 4 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 5 + "github.com/whyrusleeping/gosky/lex/util" 7 6 ) 8 7 9 8 // schema: app.bsky.feed.trend 10 9 10 + func init() { 11 + util.RegisterType("app.bsky.feed.trend", FeedTrend{}) 12 + } 13 + 11 14 // RECORDTYPE: FeedTrend 12 15 type FeedTrend struct { 13 - Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 15 - } 16 - 17 - func (t *FeedTrend) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["createdAt"] = t.CreatedAt 20 - out["subject"] = t.Subject 21 - return json.Marshal(out) 16 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.trend"` 17 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 18 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 22 19 }
+9 -13
api/bsky/feedvote.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 5 - 6 4 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 5 + "github.com/whyrusleeping/gosky/lex/util" 7 6 ) 8 7 9 8 // schema: app.bsky.feed.vote 10 9 11 - // RECORDTYPE: FeedVote 12 - type FeedVote struct { 13 - Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 - Direction string `json:"direction" cborgen:"direction"` 15 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 10 + func init() { 11 + util.RegisterType("app.bsky.feed.vote", FeedVote{}) 16 12 } 17 13 18 - func (t *FeedVote) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["createdAt"] = t.CreatedAt 21 - out["direction"] = t.Direction 22 - out["subject"] = t.Subject 23 - return json.Marshal(out) 14 + // RECORDTYPE: FeedVote 15 + type FeedVote struct { 16 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.vote"` 17 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 18 + Direction string `json:"direction" cborgen:"direction"` 19 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 24 20 }
+3
api/bsky/graphassertCreator.go
··· 2 2 3 3 // schema: app.bsky.graph.assertCreator 4 4 5 + func init() { 6 + } 7 + 5 8 const GraphAssertCreator = "app.bsky.graph.assertCreator#main"
+3
api/bsky/graphassertMember.go
··· 2 2 3 3 // schema: app.bsky.graph.assertMember 4 4 5 + func init() { 6 + } 7 + 5 8 const GraphAssertMember = "app.bsky.graph.assertMember#main"
+9 -12
api/bsky/graphassertion.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 4 + "github.com/whyrusleeping/gosky/lex/util" 5 5 ) 6 6 7 7 // schema: app.bsky.graph.assertion 8 + 9 + func init() { 10 + util.RegisterType("app.bsky.graph.assertion", GraphAssertion{}) 11 + } 8 12 9 13 // RECORDTYPE: GraphAssertion 10 14 type GraphAssertion struct { 11 - Assertion string `json:"assertion" cborgen:"assertion"` 12 - Subject *ActorRef `json:"subject" cborgen:"subject"` 13 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 14 - } 15 - 16 - func (t *GraphAssertion) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["assertion"] = t.Assertion 19 - out["createdAt"] = t.CreatedAt 20 - out["subject"] = t.Subject 21 - return json.Marshal(out) 15 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.assertion"` 16 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 17 + Assertion string `json:"assertion" cborgen:"assertion"` 18 + Subject *ActorRef `json:"subject" cborgen:"subject"` 22 19 }
+9 -13
api/bsky/graphconfirmation.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 5 - 6 4 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 5 + "github.com/whyrusleeping/gosky/lex/util" 7 6 ) 8 7 9 8 // schema: app.bsky.graph.confirmation 10 9 11 - // RECORDTYPE: GraphConfirmation 12 - type GraphConfirmation struct { 13 - Originator *ActorRef `json:"originator" cborgen:"originator"` 14 - Assertion *comatprototypes.RepoStrongRef `json:"assertion" cborgen:"assertion"` 15 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 10 + func init() { 11 + util.RegisterType("app.bsky.graph.confirmation", GraphConfirmation{}) 16 12 } 17 13 18 - func (t *GraphConfirmation) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["assertion"] = t.Assertion 21 - out["createdAt"] = t.CreatedAt 22 - out["originator"] = t.Originator 23 - return json.Marshal(out) 14 + // RECORDTYPE: GraphConfirmation 15 + type GraphConfirmation struct { 16 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.confirmation"` 17 + Originator *ActorRef `json:"originator" cborgen:"originator"` 18 + Assertion *comatprototypes.RepoStrongRef `json:"assertion" cborgen:"assertion"` 19 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 24 20 }
+8 -10
api/bsky/graphfollow.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 4 + "github.com/whyrusleeping/gosky/lex/util" 5 5 ) 6 6 7 7 // schema: app.bsky.graph.follow 8 8 9 - // RECORDTYPE: GraphFollow 10 - type GraphFollow struct { 11 - Subject *ActorRef `json:"subject" cborgen:"subject"` 12 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 9 + func init() { 10 + util.RegisterType("app.bsky.graph.follow", GraphFollow{}) 13 11 } 14 12 15 - func (t *GraphFollow) MarshalJSON() ([]byte, error) { 16 - out := make(map[string]interface{}) 17 - out["createdAt"] = t.CreatedAt 18 - out["subject"] = t.Subject 19 - return json.Marshal(out) 13 + // RECORDTYPE: GraphFollow 14 + type GraphFollow struct { 15 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.follow"` 16 + Subject *ActorRef `json:"subject" cborgen:"subject"` 17 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 20 18 }
+10 -37
api/bsky/graphgetAssertions.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.graph.getAssertions 11 10 11 + func init() { 12 + } 13 + 14 + type GraphGetAssertions_Output struct { 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 16 + Assertions []*GraphGetAssertions_Assertion `json:"assertions" cborgen:"assertions"` 17 + } 18 + 12 19 type GraphGetAssertions_Assertion struct { 20 + Cid string `json:"cid" cborgen:"cid"` 21 + Assertion string `json:"assertion" cborgen:"assertion"` 13 22 Confirmation *GraphGetAssertions_Confirmation `json:"confirmation" cborgen:"confirmation"` 14 23 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 15 24 Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 25 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 17 26 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 18 27 Uri string `json:"uri" cborgen:"uri"` 19 - Cid string `json:"cid" cborgen:"cid"` 20 - Assertion string `json:"assertion" cborgen:"assertion"` 21 - } 22 - 23 - func (t *GraphGetAssertions_Assertion) MarshalJSON() ([]byte, error) { 24 - out := make(map[string]interface{}) 25 - out["assertion"] = t.Assertion 26 - out["author"] = t.Author 27 - out["cid"] = t.Cid 28 - out["confirmation"] = t.Confirmation 29 - out["createdAt"] = t.CreatedAt 30 - out["indexedAt"] = t.IndexedAt 31 - out["subject"] = t.Subject 32 - out["uri"] = t.Uri 33 - return json.Marshal(out) 34 28 } 35 29 36 30 type GraphGetAssertions_Confirmation struct { ··· 38 32 Cid string `json:"cid" cborgen:"cid"` 39 33 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 40 34 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 41 - } 42 - 43 - func (t *GraphGetAssertions_Confirmation) MarshalJSON() ([]byte, error) { 44 - out := make(map[string]interface{}) 45 - out["cid"] = t.Cid 46 - out["createdAt"] = t.CreatedAt 47 - out["indexedAt"] = t.IndexedAt 48 - out["uri"] = t.Uri 49 - return json.Marshal(out) 50 - } 51 - 52 - type GraphGetAssertions_Output struct { 53 - Cursor string `json:"cursor" cborgen:"cursor"` 54 - Assertions []*GraphGetAssertions_Assertion `json:"assertions" cborgen:"assertions"` 55 - } 56 - 57 - func (t *GraphGetAssertions_Output) MarshalJSON() ([]byte, error) { 58 - out := make(map[string]interface{}) 59 - out["assertions"] = t.Assertions 60 - out["cursor"] = t.Cursor 61 - return json.Marshal(out) 62 35 } 63 36 64 37 func GraphGetAssertions(ctx context.Context, c *xrpc.Client, assertion string, author string, before string, confirmed bool, limit int64, subject string) (*GraphGetAssertions_Output, error) {
+13 -39
api/bsky/graphgetFollowers.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.graph.getFollowers 11 10 11 + func init() { 12 + } 13 + 14 + type GraphGetFollowers_Output struct { 15 + Subject *GraphGetFollowers_Subject `json:"subject" cborgen:"subject"` 16 + Cursor *string `json:"cursor" cborgen:"cursor"` 17 + Followers []*GraphGetFollowers_Follower `json:"followers" cborgen:"followers"` 18 + } 19 + 12 20 type GraphGetFollowers_Subject struct { 13 21 Did string `json:"did" cborgen:"did"` 14 22 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 15 23 Handle string `json:"handle" cborgen:"handle"` 16 - DisplayName string `json:"displayName" cborgen:"displayName"` 17 - } 18 - 19 - func (t *GraphGetFollowers_Subject) MarshalJSON() ([]byte, error) { 20 - out := make(map[string]interface{}) 21 - out["declaration"] = t.Declaration 22 - out["did"] = t.Did 23 - out["displayName"] = t.DisplayName 24 - out["handle"] = t.Handle 25 - return json.Marshal(out) 24 + DisplayName *string `json:"displayName" cborgen:"displayName"` 26 25 } 27 26 28 27 type GraphGetFollowers_Follower struct { 28 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 29 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 29 30 Did string `json:"did" cborgen:"did"` 30 31 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 31 32 Handle string `json:"handle" cborgen:"handle"` 32 - DisplayName string `json:"displayName" cborgen:"displayName"` 33 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 34 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 35 - } 36 - 37 - func (t *GraphGetFollowers_Follower) MarshalJSON() ([]byte, error) { 38 - out := make(map[string]interface{}) 39 - out["createdAt"] = t.CreatedAt 40 - out["declaration"] = t.Declaration 41 - out["did"] = t.Did 42 - out["displayName"] = t.DisplayName 43 - out["handle"] = t.Handle 44 - out["indexedAt"] = t.IndexedAt 45 - return json.Marshal(out) 46 - } 47 - 48 - type GraphGetFollowers_Output struct { 49 - Subject *GraphGetFollowers_Subject `json:"subject" cborgen:"subject"` 50 - Cursor string `json:"cursor" cborgen:"cursor"` 51 - Followers []*GraphGetFollowers_Follower `json:"followers" cborgen:"followers"` 52 - } 53 - 54 - func (t *GraphGetFollowers_Output) MarshalJSON() ([]byte, error) { 55 - out := make(map[string]interface{}) 56 - out["cursor"] = t.Cursor 57 - out["followers"] = t.Followers 58 - out["subject"] = t.Subject 59 - return json.Marshal(out) 33 + DisplayName *string `json:"displayName" cborgen:"displayName"` 60 34 } 61 35 62 36 func GraphGetFollowers(ctx context.Context, c *xrpc.Client, before string, limit int64, user string) (*GraphGetFollowers_Output, error) {
+6 -23
api/bsky/graphgetFollows.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.graph.getFollows 10 + 11 + func init() { 12 + } 11 13 12 14 type GraphGetFollows_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 14 16 Follows []*GraphGetFollows_Follow `json:"follows" cborgen:"follows"` 15 17 Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 18 } 17 19 18 - func (t *GraphGetFollows_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["cursor"] = t.Cursor 21 - out["follows"] = t.Follows 22 - out["subject"] = t.Subject 23 - return json.Marshal(out) 24 - } 25 - 26 20 type GraphGetFollows_Follow struct { 27 21 Did string `json:"did" cborgen:"did"` 28 22 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 29 23 Handle string `json:"handle" cborgen:"handle"` 30 - DisplayName string `json:"displayName" cborgen:"displayName"` 31 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 24 + DisplayName *string `json:"displayName" cborgen:"displayName"` 25 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 32 26 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 33 - } 34 - 35 - func (t *GraphGetFollows_Follow) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["createdAt"] = t.CreatedAt 38 - out["declaration"] = t.Declaration 39 - out["did"] = t.Did 40 - out["displayName"] = t.DisplayName 41 - out["handle"] = t.Handle 42 - out["indexedAt"] = t.IndexedAt 43 - return json.Marshal(out) 44 27 } 45 28 46 29 func GraphGetFollows(ctx context.Context, c *xrpc.Client, before string, limit int64, user string) (*GraphGetFollows_Output, error) {
+9 -26
api/bsky/graphgetMembers.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.graph.getMembers 11 10 12 - type GraphGetMembers_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 14 - Members []*GraphGetMembers_Member `json:"members" cborgen:"members"` 15 - Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 11 + func init() { 16 12 } 17 13 18 - func (t *GraphGetMembers_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["cursor"] = t.Cursor 21 - out["members"] = t.Members 22 - out["subject"] = t.Subject 23 - return json.Marshal(out) 14 + type GraphGetMembers_Output struct { 15 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 + Cursor *string `json:"cursor" cborgen:"cursor"` 17 + Members []*GraphGetMembers_Member `json:"members" cborgen:"members"` 24 18 } 25 19 26 20 type GraphGetMembers_Member struct { 27 - DisplayName string `json:"displayName" cborgen:"displayName"` 28 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 21 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 22 + Handle string `json:"handle" cborgen:"handle"` 23 + DisplayName *string `json:"displayName" cborgen:"displayName"` 24 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 29 25 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 30 26 Did string `json:"did" cborgen:"did"` 31 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 32 - Handle string `json:"handle" cborgen:"handle"` 33 - } 34 - 35 - func (t *GraphGetMembers_Member) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["createdAt"] = t.CreatedAt 38 - out["declaration"] = t.Declaration 39 - out["did"] = t.Did 40 - out["displayName"] = t.DisplayName 41 - out["handle"] = t.Handle 42 - out["indexedAt"] = t.IndexedAt 43 - return json.Marshal(out) 44 27 } 45 28 46 29 func GraphGetMembers(ctx context.Context, c *xrpc.Client, actor string, before string, limit int64) (*GraphGetMembers_Output, error) {
+9 -26
api/bsky/graphgetMemberships.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.graph.getMemberships 11 10 12 - type GraphGetMemberships_Membership struct { 13 - Did string `json:"did" cborgen:"did"` 14 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 15 - Handle string `json:"handle" cborgen:"handle"` 16 - DisplayName string `json:"displayName" cborgen:"displayName"` 17 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 18 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 19 - } 20 - 21 - func (t *GraphGetMemberships_Membership) MarshalJSON() ([]byte, error) { 22 - out := make(map[string]interface{}) 23 - out["createdAt"] = t.CreatedAt 24 - out["declaration"] = t.Declaration 25 - out["did"] = t.Did 26 - out["displayName"] = t.DisplayName 27 - out["handle"] = t.Handle 28 - out["indexedAt"] = t.IndexedAt 29 - return json.Marshal(out) 11 + func init() { 30 12 } 31 13 32 14 type GraphGetMemberships_Output struct { 33 15 Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 34 - Cursor string `json:"cursor" cborgen:"cursor"` 16 + Cursor *string `json:"cursor" cborgen:"cursor"` 35 17 Memberships []*GraphGetMemberships_Membership `json:"memberships" cborgen:"memberships"` 36 18 } 37 19 38 - func (t *GraphGetMemberships_Output) MarshalJSON() ([]byte, error) { 39 - out := make(map[string]interface{}) 40 - out["cursor"] = t.Cursor 41 - out["memberships"] = t.Memberships 42 - out["subject"] = t.Subject 43 - return json.Marshal(out) 20 + type GraphGetMemberships_Membership struct { 21 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 22 + Did string `json:"did" cborgen:"did"` 23 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 24 + Handle string `json:"handle" cborgen:"handle"` 25 + DisplayName *string `json:"displayName" cborgen:"displayName"` 26 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 44 27 } 45 28 46 29 func GraphGetMemberships(ctx context.Context, c *xrpc.Client, actor string, before string, limit int64) (*GraphGetMemberships_Output, error) {
+3 -7
api/bsky/notificationgetCount.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.notification.getCount 11 10 12 - type NotificationGetCount_Output struct { 13 - Count int64 `json:"count" cborgen:"count"` 11 + func init() { 14 12 } 15 13 16 - func (t *NotificationGetCount_Output) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["count"] = t.Count 19 - return json.Marshal(out) 14 + type NotificationGetCount_Output struct { 15 + Count int64 `json:"count" cborgen:"count"` 20 16 } 21 17 22 18 func NotificationGetCount(ctx context.Context, c *xrpc.Client) (*NotificationGetCount_Output, error) {
+7 -25
api/bsky/notificationlist.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.notification.list 11 10 12 - type NotificationList_Output struct { 13 - Cursor string `json:"cursor" cborgen:"cursor"` 14 - Notifications []*NotificationList_Notification `json:"notifications" cborgen:"notifications"` 11 + func init() { 15 12 } 16 13 17 - func (t *NotificationList_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["cursor"] = t.Cursor 20 - out["notifications"] = t.Notifications 21 - return json.Marshal(out) 14 + type NotificationList_Output struct { 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 16 + Notifications []*NotificationList_Notification `json:"notifications" cborgen:"notifications"` 22 17 } 23 18 24 19 type NotificationList_Notification struct { 20 + Reason string `json:"reason" cborgen:"reason"` 21 + ReasonSubject *string `json:"reasonSubject" cborgen:"reasonSubject"` 22 + Record any `json:"record" cborgen:"record"` 25 23 IsRead bool `json:"isRead" cborgen:"isRead"` 26 24 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 27 25 Uri string `json:"uri" cborgen:"uri"` 28 26 Cid string `json:"cid" cborgen:"cid"` 29 27 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 30 - Reason string `json:"reason" cborgen:"reason"` 31 - ReasonSubject string `json:"reasonSubject" cborgen:"reasonSubject"` 32 - Record any `json:"record" cborgen:"record"` 33 - } 34 - 35 - func (t *NotificationList_Notification) MarshalJSON() ([]byte, error) { 36 - out := make(map[string]interface{}) 37 - out["author"] = t.Author 38 - out["cid"] = t.Cid 39 - out["indexedAt"] = t.IndexedAt 40 - out["isRead"] = t.IsRead 41 - out["reason"] = t.Reason 42 - out["reasonSubject"] = t.ReasonSubject 43 - out["record"] = t.Record 44 - out["uri"] = t.Uri 45 - return json.Marshal(out) 46 28 } 47 29 48 30 func NotificationList(ctx context.Context, c *xrpc.Client, before string, limit int64) (*NotificationList_Output, error) {
+3 -7
api/bsky/notificationupdateSeen.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "encoding/json" 6 5 7 6 "github.com/whyrusleeping/gosky/xrpc" 8 7 ) 9 8 10 9 // schema: app.bsky.notification.updateSeen 11 10 12 - type NotificationUpdateSeen_Input struct { 13 - SeenAt string `json:"seenAt" cborgen:"seenAt"` 11 + func init() { 14 12 } 15 13 16 - func (t *NotificationUpdateSeen_Input) MarshalJSON() ([]byte, error) { 17 - out := make(map[string]interface{}) 18 - out["seenAt"] = t.SeenAt 19 - return json.Marshal(out) 14 + type NotificationUpdateSeen_Input struct { 15 + SeenAt string `json:"seenAt" cborgen:"seenAt"` 20 16 } 21 17 22 18 func NotificationUpdateSeen(ctx context.Context, c *xrpc.Client, input NotificationUpdateSeen_Input) error {
+3
api/bsky/systemactorScene.go
··· 2 2 3 3 // schema: app.bsky.system.actorScene 4 4 5 + func init() { 6 + } 7 + 5 8 const SystemActorScene = "app.bsky.system.actorScene#main"
+3
api/bsky/systemactorUser.go
··· 2 2 3 3 // schema: app.bsky.system.actorUser 4 4 5 + func init() { 6 + } 7 + 5 8 const SystemActorUser = "app.bsky.system.actorUser#main"
+4 -12
api/bsky/systemdeclRef.go
··· 1 1 package schemagen 2 2 3 - import ( 4 - "encoding/json" 5 - ) 6 - 7 3 // schema: app.bsky.system.declRef 8 4 9 - type SystemDeclRef struct { 10 - Cid string `json:"cid" cborgen:"cid"` 11 - ActorType string `json:"actorType" cborgen:"actorType"` 5 + func init() { 12 6 } 13 7 14 - func (t *SystemDeclRef) MarshalJSON() ([]byte, error) { 15 - out := make(map[string]interface{}) 16 - out["actorType"] = t.ActorType 17 - out["cid"] = t.Cid 18 - return json.Marshal(out) 8 + type SystemDeclRef struct { 9 + ActorType string `json:"actorType" cborgen:"actorType"` 10 + Cid string `json:"cid" cborgen:"cid"` 19 11 }
+7 -8
api/bsky/systemdeclaration.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 - "encoding/json" 4 + "github.com/whyrusleeping/gosky/lex/util" 5 5 ) 6 6 7 7 // schema: app.bsky.system.declaration 8 8 9 + func init() { 10 + util.RegisterType("app.bsky.system.declaration", SystemDeclaration{}) 11 + } 12 + 9 13 // RECORDTYPE: SystemDeclaration 10 14 type SystemDeclaration struct { 11 - ActorType string `json:"actorType" cborgen:"actorType"` 12 - } 13 - 14 - func (t *SystemDeclaration) MarshalJSON() ([]byte, error) { 15 - out := make(map[string]interface{}) 16 - out["actorType"] = t.ActorType 17 - return json.Marshal(out) 15 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.system.declaration"` 16 + ActorType string `json:"actorType" cborgen:"actorType"` 18 17 }
+139 -7
api/server/feedgen.go
··· 4 4 "context" 5 5 "fmt" 6 6 "log" 7 + "strings" 7 8 "time" 8 9 9 10 "github.com/ipfs/go-cid" ··· 16 17 type FeedGenerator struct { 17 18 db *gorm.DB 18 19 19 - readRecord func(context.Context, uint, cid.Cid) (any, error) 20 + readRecord ReadRecordFunc 20 21 } 22 + 23 + type ReadRecordFunc func(context.Context, uint, cid.Cid) (any, error) 21 24 22 25 type FeedPost struct { 23 26 gorm.Model ··· 44 47 Type string 45 48 } 46 49 47 - func NewFeedGenerator(db *gorm.DB) (*FeedGenerator, error) { 50 + type UpVoteRecord struct { 51 + gorm.Model 52 + User uint 53 + Likes uint 54 + } 55 + 56 + type FollowRecord struct { 57 + gorm.Model 58 + User uint 59 + Follows uint 60 + } 61 + 62 + func NewFeedGenerator(db *gorm.DB, readRecord ReadRecordFunc) (*FeedGenerator, error) { 48 63 db.AutoMigrate(&FeedPost{}) 49 64 db.AutoMigrate(&ActorInfo{}) 65 + db.AutoMigrate(&FollowRecord{}) 66 + db.AutoMigrate(&UpVoteRecord{}) 50 67 51 68 return &FeedGenerator{ 52 - db: db, 69 + db: db, 70 + readRecord: readRecord, 53 71 }, nil 54 72 } 55 73 ··· 106 124 } 107 125 108 126 out := bsky.ActorRef_WithInfo{ 109 - Did: ai.Did, 110 - Declaration: nil, //TODO: 127 + Did: ai.Did, 128 + Declaration: &bsky.SystemDeclRef{ 129 + Cid: ai.DeclRefCid, 130 + ActorType: ai.Type, 131 + }, 111 132 Handle: ai.Handle, 112 - DisplayName: ai.Name, 133 + DisplayName: &ai.Name, 113 134 } 114 135 115 136 return &out, nil ··· 156 177 out.RepostedBy = rp 157 178 } 158 179 159 - rec, err := fg.readRecord(ctx, item.Author, item.RecCid) 180 + reccid, err := cid.Decode(item.Cid) 181 + if err != nil { 182 + return nil, err 183 + } 184 + 185 + rec, err := fg.readRecord(ctx, item.Author, reccid) 160 186 if err != nil { 161 187 return nil, err 162 188 } 163 189 190 + out.Record = rec 191 + 164 192 return &out, nil 193 + } 194 + 195 + func (fg *FeedGenerator) GetTimeline(ctx context.Context, user uint, algo string, before string, limit int) ([]*HydratedFeedItem, error) { 196 + ctx, span := otel.Tracer("feedgen").Start(context.Background(), "GetTimeline") 197 + defer span.End() 198 + 199 + // TODO: this query is just a temporary hack... 200 + var feed []*FeedPost 201 + if err := fg.db.Find(&feed, "author = (?) OR reposted_by = (?)", 202 + fg.db.Model(FollowRecord{}).Where("user = ?", user).Select("follows"), 203 + fg.db.Model(FollowRecord{}).Where("user = ?", user).Select("follows"), 204 + ).Error; err != nil { 205 + return nil, err 206 + } 207 + 208 + return fg.hydrateFeed(ctx, feed) 165 209 } 166 210 167 211 func (fg *FeedGenerator) GetAuthorFeed(ctx context.Context, user uint, before string, limit int) ([]*HydratedFeedItem, error) { ··· 217 261 return err 218 262 } 219 263 264 + if err := fg.db.Create(&FollowRecord{ 265 + User: evt.User, 266 + Follows: evt.User, 267 + }).Error; err != nil { 268 + return err 269 + } 270 + 220 271 return nil 221 272 } 222 273 274 + type parsedUri struct { 275 + Did string 276 + Rkey string 277 + } 278 + 279 + func parseAtUri(uri string) (*parsedUri, error) { 280 + if !strings.HasPrefix(uri, "at://") { 281 + return nil, fmt.Errorf("AT uris must be prefixed with 'at://'") 282 + } 283 + 284 + trimmed := strings.TrimPrefix(uri, "at://") 285 + parts := strings.Split(trimmed, "/") 286 + if len(parts) != 3 { 287 + return nil, fmt.Errorf("AT uris must have three parts: did, collection, tid") 288 + } 289 + 290 + did := parts[0] 291 + rkey := parts[1] + "/" + parts[2] 292 + 293 + return &parsedUri{ 294 + Did: did, 295 + Rkey: rkey, 296 + }, nil 297 + } 298 + 223 299 func (fg *FeedGenerator) handleRecordCreate(ctx context.Context, evt *repomgr.RepoEvent) error { 224 300 switch rec := evt.Record.(type) { 225 301 case *bsky.FeedPost: ··· 236 312 return err 237 313 } 238 314 return nil 315 + case *bsky.FeedVote: 316 + var val int 317 + switch rec.Direction { 318 + case "up": 319 + val = 1 320 + case "down": 321 + val = -1 322 + default: 323 + return fmt.Errorf("invalid vote direction: %q", rec.Direction) 324 + } 325 + 326 + puri, err := parseAtUri(rec.Subject.Uri) 327 + if err != nil { 328 + return err 329 + } 330 + 331 + act, err := fg.lookupUserByDid(ctx, puri.Did) 332 + if err != nil { 333 + return err 334 + } 335 + 336 + var post FeedPost 337 + if err := fg.db.First(&post, "tid = ? AND author = ?", puri.Rkey, act.User).Error; err != nil { 338 + return err 339 + } 340 + 341 + if err := fg.db.Create(&UpVoteRecord{ 342 + User: evt.User, 343 + Likes: post.ID, 344 + }).Error; err != nil { 345 + return err 346 + } 347 + 348 + if err := fg.db.Model(FeedPost{}).Where("id = ?", post.ID).Update("up_count", gorm.Expr("up_count + ?", val)).Error; err != nil { 349 + return err 350 + } 351 + 352 + return nil 239 353 default: 240 354 return fmt.Errorf("unrecognized record type: %T", rec) 241 355 } 242 356 } 243 357 358 + func (fg *FeedGenerator) lookupUserByDid(ctx context.Context, did string) (*ActorInfo, error) { 359 + var ai ActorInfo 360 + if err := fg.db.First(&ai, "did = ?", did).Error; err != nil { 361 + return nil, err 362 + } 363 + 364 + return &ai, nil 365 + } 366 + 244 367 func (fg *FeedGenerator) addNewPostNotification(ctx context.Context, user uint, postid uint) error { 245 368 // TODO: 246 369 return nil 247 370 } 371 + 372 + func (fg *FeedGenerator) GetActorProfile(ctx context.Context, actor string) (*ActorInfo, error) { 373 + var ai ActorInfo 374 + if err := fg.db.First(&ai, "handle = ?", actor).Error; err != nil { 375 + return nil, err 376 + } 377 + 378 + return nil, nil 379 + }
+171 -14
api/server/handlers.go
··· 5 5 "context" 6 6 "fmt" 7 7 "io" 8 + "time" 8 9 9 10 "github.com/ipfs/go-cid" 10 11 cbg "github.com/whyrusleeping/cbor-gen" ··· 17 18 } 18 19 19 20 func (s *Server) handleAppBskyActorGetProfile(ctx context.Context, actor string) (*appbskytypes.ActorGetProfile_Output, error) { 20 - panic("not yet implemented") 21 + fmt.Println("Get profile:", actor) 22 + 23 + return nil, nil 24 + 25 + /* 26 + profile, err := s.feedgen.GetActorProfile(ctx, actor) 27 + if err != nil { 28 + return nil, err 29 + } 30 + 31 + var out appbskytypes.ActorGetProfile_Output 32 + out := ActorGetProfile_Output { 33 + MyState : nil, //*ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 34 + Did string `json:"did" cborgen:"did"` 35 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 36 + Description string `json:"description" cborgen:"description"` 37 + PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 38 + FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 39 + MembersCount int64 `json:"membersCount" cborgen:"membersCount"` 40 + Handle string `json:"handle" cborgen:"handle"` 41 + Creator string `json:"creator" cborgen:"creator"` 42 + DisplayName string `json:"displayName" cborgen:"displayName"` 43 + FollowersCount int64 `json:"followersCount" cborgen:"followersCount"` 44 + } 45 + */ 21 46 } 22 47 23 48 func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context, cursor string, limit int) (*appbskytypes.ActorGetSuggestions_Output, error) { 24 - panic("not yet implemented") 49 + 50 + var out appbskytypes.ActorGetSuggestions_Output 51 + out.Actors = []*appbskytypes.ActorGetSuggestions_Actor{} 52 + return &out, nil 25 53 } 26 54 27 55 func (s *Server) handleAppBskyActorSearch(ctx context.Context, before string, limit int, term string) (*appbskytypes.ActorSearch_Output, error) { ··· 84 112 } 85 113 86 114 func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context, algorithm string, before string, limit int) (*appbskytypes.FeedGetTimeline_Output, error) { 87 - panic("not yet implemented") 115 + u, err := s.getUser(ctx) 116 + if err != nil { 117 + return nil, err 118 + } 119 + 120 + tl, err := s.feedgen.GetTimeline(ctx, u.ID, algorithm, before, limit) 121 + if err != nil { 122 + return nil, err 123 + } 124 + 125 + var out appbskytypes.FeedGetTimeline_Output 126 + out.Feed = []*appbskytypes.FeedGetTimeline_FeedItem{} 127 + 128 + for _, fi := range tl { 129 + out.Feed = append(out.Feed, &appbskytypes.FeedGetTimeline_FeedItem{ 130 + Uri: fi.Uri, 131 + RepostedBy: fi.RepostedBy, 132 + Record: fi.Record, 133 + ReplyCount: fi.ReplyCount, 134 + RepostCount: fi.RepostCount, 135 + UpvoteCount: fi.UpvoteCount, 136 + DownvoteCount: 0, 137 + MyState: nil, // TODO: 138 + Cid: fi.Cid, 139 + Author: fi.Author, 140 + TrendedBy: fi.TrendedBy, 141 + Embed: nil, 142 + IndexedAt: fi.IndexedAt, 143 + }) 144 + } 145 + 146 + return &out, nil 88 147 } 89 148 90 149 func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context, before string, cid string, direction string, limit int, uri string) (*appbskytypes.FeedGetVotes_Output, error) { ··· 92 151 } 93 152 94 153 func (s *Server) handleAppBskyFeedSetVote(ctx context.Context, input *appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error) { 95 - panic("not yet implemented") 154 + u, err := s.getUser(ctx) 155 + if err != nil { 156 + return nil, err 157 + } 158 + 159 + // TODO: check subject actually exists maybe? 160 + vote := &appbskytypes.FeedVote{ 161 + Direction: input.Direction, 162 + CreatedAt: time.Now().Format(time.RFC3339), 163 + Subject: input.Subject, 164 + } 165 + 166 + rkey, cc, err := s.repoman.CreateRecord(ctx, u.ID, "app.bsky.feed.vote", vote) 167 + if err != nil { 168 + return nil, err 169 + } 170 + 171 + _ = rkey 172 + _ = cc 173 + 174 + var out appbskytypes.FeedSetVote_Output 175 + // TODO: what is this supposed to return? 176 + return &out, nil 96 177 } 97 178 98 179 func (s *Server) handleAppBskyGraphGetAssertions(ctx context.Context, assertion string, author string, before string) (*appbskytypes.GraphGetAssertions_Output, error) { ··· 116 197 } 117 198 118 199 func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error) { 119 - panic("not yet implemented") 200 + fmt.Println("Notification Count not yet implemented!") 201 + 202 + return &appbskytypes.NotificationGetCount_Output{}, nil 120 203 } 121 204 122 205 func (s *Server) handleAppBskyNotificationList(ctx context.Context, before string, limit int) (*appbskytypes.NotificationList_Output, error) { 123 - panic("not yet implemented") 206 + 207 + fmt.Println("notifications not yet implemented!") 208 + out := appbskytypes.NotificationList_Output{ 209 + Notifications: []*appbskytypes.NotificationList_Notification{}, 210 + } 211 + 212 + return &out, nil 124 213 } 125 214 126 215 func (s *Server) handleAppBskyNotificationUpdateSeen(ctx context.Context, input *appbskytypes.NotificationUpdateSeen_Input) error { 127 - panic("not yet implemented") 216 + fmt.Println("notifications not yet implemented update seen!") 217 + 218 + return nil 128 219 } 129 220 130 221 func (s *Server) handleComAtprotoAccountCreate(ctx context.Context, input *comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) { ··· 138 229 139 230 } 140 231 232 + var recoveryKey string 233 + if input.RecoveryKey != nil { 234 + recoveryKey = *input.RecoveryKey 235 + } 236 + 141 237 u := User{ 142 238 Handle: input.Handle, 143 239 Password: input.Password, 144 - RecoveryKey: input.RecoveryKey, 240 + RecoveryKey: recoveryKey, 145 241 Email: input.Email, 146 242 } 147 243 if err := s.db.Create(&u).Error; err != nil { ··· 153 249 return nil, err 154 250 } 155 251 252 + u.DID = d 253 + if err := s.db.Save(&u).Error; err != nil { 254 + return nil, err 255 + } 256 + 156 257 if err := s.repoman.InitNewActor(ctx, u.ID, u.Handle, u.DID, "", UserActorDeclCid, UserActorDeclType); err != nil { 157 258 return nil, err 158 259 } ··· 191 292 } 192 293 193 294 func (s *Server) handleComAtprotoHandleResolve(ctx context.Context, handle string) (*comatprototypes.HandleResolve_Output, error) { 194 - panic("not yet implemented") 295 + 296 + u, err := s.lookupUserByHandle(ctx, handle) 297 + if err != nil { 298 + return nil, err 299 + } 300 + 301 + return &comatprototypes.HandleResolve_Output{u.DID}, nil 195 302 } 196 303 197 304 func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context, input *comatprototypes.RepoBatchWrite_Input) error { ··· 238 345 panic("not yet implemented") 239 346 } 240 347 241 - func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context, cid string, collection string, rkey string, user string) (*comatprototypes.RepoGetRecord_Output, error) { 242 - panic("not yet implemented") 348 + func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context, c string, collection string, rkey string, user string) (*comatprototypes.RepoGetRecord_Output, error) { 349 + targetUser, err := s.lookupUser(ctx, user) 350 + if err != nil { 351 + return nil, err 352 + } 353 + 354 + var maybeCid cid.Cid 355 + if c != "" { 356 + cc, err := cid.Decode(c) 357 + if err != nil { 358 + return nil, err 359 + } 360 + maybeCid = cc 361 + } 362 + 363 + reccid, rec, err := s.repoman.GetRecord(ctx, targetUser.ID, collection, rkey, maybeCid) 364 + if err != nil { 365 + return nil, err 366 + } 367 + 368 + ccstr := reccid.String() 369 + return &comatprototypes.RepoGetRecord_Output{ 370 + Cid: &ccstr, 371 + Uri: "at://" + targetUser.DID + "/" + collection + "/" + rkey, 372 + Value: rec, 373 + }, nil 243 374 } 244 375 245 376 func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context, after string, before string, collection string, limit int) (*comatprototypes.RepoListRecords_Output, error) { ··· 251 382 } 252 383 253 384 func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) { 254 - panic("not yet implemented") 385 + invcode := false 386 + return &comatprototypes.ServerGetAccountsConfig_Output{ 387 + InviteCodeRequired: &invcode, 388 + AvailableUserDomains: []string{ 389 + s.handleSuffix, 390 + }, 391 + }, nil 255 392 } 256 393 257 394 func (s *Server) handleComAtprotoSessionCreate(ctx context.Context, input *comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) { ··· 282 419 } 283 420 284 421 func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error) { 285 - panic("not yet implemented") 422 + u, err := s.getUser(ctx) 423 + if err != nil { 424 + return nil, err 425 + } 426 + 427 + return &comatprototypes.SessionGet_Output{ 428 + Handle: u.Handle, 429 + Did: u.DID, 430 + }, nil 286 431 } 287 432 288 433 func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error) { ··· 314 459 } 315 460 316 461 func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context, did string) (*comatprototypes.SyncGetRoot_Output, error) { 317 - panic("not yet implemented") 462 + user, err := s.lookupUserByDid(ctx, did) 463 + if err != nil { 464 + return nil, err 465 + } 466 + 467 + root, err := s.repoman.GetRepoRoot(ctx, user.ID) 468 + if err != nil { 469 + return nil, err 470 + } 471 + 472 + return &comatprototypes.SyncGetRoot_Output{ 473 + Root: root.String(), 474 + }, nil 318 475 } 319 476 320 477 func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context, r io.Reader) error {
+40 -14
api/server/server.go
··· 12 12 "time" 13 13 14 14 "github.com/golang-jwt/jwt" 15 + "github.com/ipfs/go-cid" 15 16 "github.com/labstack/echo/v4" 16 17 "github.com/labstack/echo/v4/middleware" 17 18 jwk "github.com/lestrrat-go/jwx/jwk" 18 19 "github.com/whyrusleeping/gosky/carstore" 20 + "github.com/whyrusleeping/gosky/lex/util" 19 21 "github.com/whyrusleeping/gosky/repomgr" 20 22 "gorm.io/gorm" 21 23 ) ··· 43 45 return nil, err 44 46 } 45 47 46 - feedgen, err := NewFeedGenerator(db) 47 - if err != nil { 48 - return nil, err 49 - } 50 - 51 - repoman := repomgr.NewRepoManager(db, cs, feedgen.HandleRepoEvent) 52 - 53 - return &Server{ 48 + s := &Server{ 54 49 signingKey: serkey, 55 50 db: db, 56 51 cs: cs, 57 - repoman: repoman, 58 - feedgen: feedgen, 59 52 fakeDid: NewFakeDid(db), 60 53 handleSuffix: ".pdstest", 61 - }, nil 54 + } 55 + 56 + feedgen, err := NewFeedGenerator(db, s.readRecordFunc) 57 + if err != nil { 58 + return nil, err 59 + } 60 + 61 + s.feedgen = feedgen 62 + s.repoman = repomgr.NewRepoManager(db, cs, feedgen.HandleRepoEvent) 62 63 64 + return s, nil 65 + } 66 + 67 + func (s *Server) readRecordFunc(ctx context.Context, user uint, c cid.Cid) (any, error) { 68 + bs, err := s.cs.ReadOnlySession(user) 69 + if err != nil { 70 + return nil, err 71 + } 72 + 73 + blk, err := bs.Get(ctx, c) 74 + if err != nil { 75 + return nil, err 76 + } 77 + 78 + return util.CborDecodeValue(blk.RawData()) 63 79 } 64 80 65 81 func loadKey(kfile string) ([]byte, error) { ··· 91 107 return true 92 108 case "/xrpc/com.atproto.session.create": 93 109 return true 110 + case "/xrpc/com.atproto.server.getAccountsConfig": 111 + return true 94 112 default: 95 113 return false 96 114 } ··· 112 130 113 131 type User struct { 114 132 gorm.Model 115 - Handle string 133 + Handle string `gorm:"uniqueIndex"` 116 134 Password string 117 135 RecoveryKey string 118 136 Email string 119 - DID string 137 + DID string `gorm:"uniqueIndex"` 120 138 } 121 139 122 140 func toTime(i interface{}) (time.Time, error) { ··· 185 203 return scopestr, didstr, nil 186 204 } 187 205 188 - func (s *Server) lookupUser(ctx context.Context, did string) (*User, error) { 206 + func (s *Server) lookupUser(ctx context.Context, didorhandle string) (*User, error) { 207 + if strings.HasPrefix(didorhandle, "did:") { 208 + return s.lookupUserByDid(ctx, didorhandle) 209 + } 210 + 211 + return s.lookupUserByHandle(ctx, didorhandle) 212 + } 213 + 214 + func (s *Server) lookupUserByDid(ctx context.Context, did string) (*User, error) { 189 215 var didEntry FakeDidMapping 190 216 if err := s.db.First(&didEntry, "did = ?", did).Error; err != nil { 191 217 return nil, err
+367 -368
api/server/stubs.go
··· 10 10 "go.opentelemetry.io/otel" 11 11 ) 12 12 13 + func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 14 + e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate) 15 + e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 16 + e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) 17 + e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 18 + e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset) 19 + e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword) 20 + e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve) 21 + e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite) 22 + e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord) 23 + e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord) 24 + e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe) 25 + e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 26 + e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 27 + e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord) 28 + e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 29 + e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate) 30 + e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete) 31 + e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet) 32 + e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh) 33 + e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo) 34 + e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot) 35 + e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo) 36 + return nil 37 + } 38 + 39 + func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error { 40 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate") 41 + defer span.End() 42 + 43 + var body comatprototypes.AccountCreate_Input 44 + if err := c.Bind(&body); err != nil { 45 + return err 46 + } 47 + var out *comatprototypes.AccountCreate_Output 48 + var handleErr error 49 + // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) 50 + out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body) 51 + if handleErr != nil { 52 + return handleErr 53 + } 54 + return c.JSON(200, out) 55 + } 56 + 57 + func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error { 58 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode") 59 + defer span.End() 60 + 61 + var body comatprototypes.AccountCreateInviteCode_Input 62 + if err := c.Bind(&body); err != nil { 63 + return err 64 + } 65 + var out *comatprototypes.AccountCreateInviteCode_Output 66 + var handleErr error 67 + // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error) 68 + out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body) 69 + if handleErr != nil { 70 + return handleErr 71 + } 72 + return c.JSON(200, out) 73 + } 74 + 75 + func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error { 76 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete") 77 + defer span.End() 78 + var handleErr error 79 + // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error 80 + handleErr = s.handleComAtprotoAccountDelete(ctx) 81 + if handleErr != nil { 82 + return handleErr 83 + } 84 + return nil 85 + } 86 + 87 + func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error { 88 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet") 89 + defer span.End() 90 + var handleErr error 91 + // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 92 + handleErr = s.handleComAtprotoAccountGet(ctx) 93 + if handleErr != nil { 94 + return handleErr 95 + } 96 + return nil 97 + } 98 + 99 + func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error { 100 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset") 101 + defer span.End() 102 + 103 + var body comatprototypes.AccountRequestPasswordReset_Input 104 + if err := c.Bind(&body); err != nil { 105 + return err 106 + } 107 + var handleErr error 108 + // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error 109 + handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body) 110 + if handleErr != nil { 111 + return handleErr 112 + } 113 + return nil 114 + } 115 + 116 + func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error { 117 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword") 118 + defer span.End() 119 + 120 + var body comatprototypes.AccountResetPassword_Input 121 + if err := c.Bind(&body); err != nil { 122 + return err 123 + } 124 + var handleErr error 125 + // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error 126 + handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body) 127 + if handleErr != nil { 128 + return handleErr 129 + } 130 + return nil 131 + } 132 + 133 + func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error { 134 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve") 135 + defer span.End() 136 + handle := c.QueryParam("handle") 137 + var out *comatprototypes.HandleResolve_Output 138 + var handleErr error 139 + // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error) 140 + out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle) 141 + if handleErr != nil { 142 + return handleErr 143 + } 144 + return c.JSON(200, out) 145 + } 146 + 147 + func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error { 148 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite") 149 + defer span.End() 150 + 151 + var body comatprototypes.RepoBatchWrite_Input 152 + if err := c.Bind(&body); err != nil { 153 + return err 154 + } 155 + var handleErr error 156 + // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error 157 + handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body) 158 + if handleErr != nil { 159 + return handleErr 160 + } 161 + return nil 162 + } 163 + 164 + func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error { 165 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord") 166 + defer span.End() 167 + 168 + var body comatprototypes.RepoCreateRecord_Input 169 + if err := c.Bind(&body); err != nil { 170 + return err 171 + } 172 + var out *comatprototypes.RepoCreateRecord_Output 173 + var handleErr error 174 + // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error) 175 + out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body) 176 + if handleErr != nil { 177 + return handleErr 178 + } 179 + return c.JSON(200, out) 180 + } 181 + 182 + func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error { 183 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord") 184 + defer span.End() 185 + 186 + var body comatprototypes.RepoDeleteRecord_Input 187 + if err := c.Bind(&body); err != nil { 188 + return err 189 + } 190 + var handleErr error 191 + // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error 192 + handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body) 193 + if handleErr != nil { 194 + return handleErr 195 + } 196 + return nil 197 + } 198 + 199 + func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error { 200 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe") 201 + defer span.End() 202 + user := c.QueryParam("user") 203 + var out *comatprototypes.RepoDescribe_Output 204 + var handleErr error 205 + // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error) 206 + out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user) 207 + if handleErr != nil { 208 + return handleErr 209 + } 210 + return c.JSON(200, out) 211 + } 212 + 213 + func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 214 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 215 + defer span.End() 216 + cid := c.QueryParam("cid") 217 + collection := c.QueryParam("collection") 218 + rkey := c.QueryParam("rkey") 219 + user := c.QueryParam("user") 220 + var out *comatprototypes.RepoGetRecord_Output 221 + var handleErr error 222 + // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error) 223 + out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user) 224 + if handleErr != nil { 225 + return handleErr 226 + } 227 + return c.JSON(200, out) 228 + } 229 + 230 + func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 231 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 232 + defer span.End() 233 + after := c.QueryParam("after") 234 + before := c.QueryParam("before") 235 + collection := c.QueryParam("collection") 236 + 237 + limit, err := strconv.Atoi(c.QueryParam("limit")) 238 + if err != nil { 239 + return err 240 + } 241 + var out *comatprototypes.RepoListRecords_Output 242 + var handleErr error 243 + // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error) 244 + out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit) 245 + if handleErr != nil { 246 + return handleErr 247 + } 248 + return c.JSON(200, out) 249 + } 250 + 251 + func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error { 252 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord") 253 + defer span.End() 254 + 255 + var body comatprototypes.RepoPutRecord_Input 256 + if err := c.Bind(&body); err != nil { 257 + return err 258 + } 259 + var out *comatprototypes.RepoPutRecord_Output 260 + var handleErr error 261 + // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error) 262 + out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body) 263 + if handleErr != nil { 264 + return handleErr 265 + } 266 + return c.JSON(200, out) 267 + } 268 + 269 + func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 270 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 271 + defer span.End() 272 + var out *comatprototypes.ServerGetAccountsConfig_Output 273 + var handleErr error 274 + // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) 275 + out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 276 + if handleErr != nil { 277 + return handleErr 278 + } 279 + return c.JSON(200, out) 280 + } 281 + 282 + func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error { 283 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate") 284 + defer span.End() 285 + 286 + var body comatprototypes.SessionCreate_Input 287 + if err := c.Bind(&body); err != nil { 288 + return err 289 + } 290 + var out *comatprototypes.SessionCreate_Output 291 + var handleErr error 292 + // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) 293 + out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body) 294 + if handleErr != nil { 295 + return handleErr 296 + } 297 + return c.JSON(200, out) 298 + } 299 + 300 + func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error { 301 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete") 302 + defer span.End() 303 + var handleErr error 304 + // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error 305 + handleErr = s.handleComAtprotoSessionDelete(ctx) 306 + if handleErr != nil { 307 + return handleErr 308 + } 309 + return nil 310 + } 311 + 312 + func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error { 313 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet") 314 + defer span.End() 315 + var out *comatprototypes.SessionGet_Output 316 + var handleErr error 317 + // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error) 318 + out, handleErr = s.handleComAtprotoSessionGet(ctx) 319 + if handleErr != nil { 320 + return handleErr 321 + } 322 + return c.JSON(200, out) 323 + } 324 + 325 + func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error { 326 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh") 327 + defer span.End() 328 + var out *comatprototypes.SessionRefresh_Output 329 + var handleErr error 330 + // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error) 331 + out, handleErr = s.handleComAtprotoSessionRefresh(ctx) 332 + if handleErr != nil { 333 + return handleErr 334 + } 335 + return c.JSON(200, out) 336 + } 337 + 338 + func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 339 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 340 + defer span.End() 341 + did := c.QueryParam("did") 342 + from := c.QueryParam("from") 343 + var out io.Reader 344 + var handleErr error 345 + // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 346 + out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 347 + if handleErr != nil { 348 + return handleErr 349 + } 350 + return c.JSON(200, out) 351 + } 352 + 353 + func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error { 354 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot") 355 + defer span.End() 356 + did := c.QueryParam("did") 357 + var out *comatprototypes.SyncGetRoot_Output 358 + var handleErr error 359 + // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error) 360 + out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did) 361 + if handleErr != nil { 362 + return handleErr 363 + } 364 + return c.JSON(200, out) 365 + } 366 + 367 + func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error { 368 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo") 369 + defer span.End() 370 + body := c.Request().Body 371 + var handleErr error 372 + // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error 373 + handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body) 374 + if handleErr != nil { 375 + return handleErr 376 + } 377 + return nil 378 + } 379 + 13 380 func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 14 381 e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene) 15 382 e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) ··· 406 773 } 407 774 return nil 408 775 } 409 - 410 - func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 411 - e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate) 412 - e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 413 - e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) 414 - e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 415 - e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset) 416 - e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword) 417 - e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve) 418 - e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite) 419 - e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord) 420 - e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord) 421 - e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe) 422 - e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 423 - e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 424 - e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord) 425 - e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 426 - e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate) 427 - e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete) 428 - e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet) 429 - e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh) 430 - e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo) 431 - e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot) 432 - e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo) 433 - return nil 434 - } 435 - 436 - func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error { 437 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate") 438 - defer span.End() 439 - 440 - var body comatprototypes.AccountCreate_Input 441 - if err := c.Bind(&body); err != nil { 442 - return err 443 - } 444 - var out *comatprototypes.AccountCreate_Output 445 - var handleErr error 446 - // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) 447 - out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body) 448 - if handleErr != nil { 449 - return handleErr 450 - } 451 - return c.JSON(200, out) 452 - } 453 - 454 - func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error { 455 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode") 456 - defer span.End() 457 - 458 - var body comatprototypes.AccountCreateInviteCode_Input 459 - if err := c.Bind(&body); err != nil { 460 - return err 461 - } 462 - var out *comatprototypes.AccountCreateInviteCode_Output 463 - var handleErr error 464 - // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error) 465 - out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body) 466 - if handleErr != nil { 467 - return handleErr 468 - } 469 - return c.JSON(200, out) 470 - } 471 - 472 - func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error { 473 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete") 474 - defer span.End() 475 - var handleErr error 476 - // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error 477 - handleErr = s.handleComAtprotoAccountDelete(ctx) 478 - if handleErr != nil { 479 - return handleErr 480 - } 481 - return nil 482 - } 483 - 484 - func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error { 485 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet") 486 - defer span.End() 487 - var handleErr error 488 - // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 489 - handleErr = s.handleComAtprotoAccountGet(ctx) 490 - if handleErr != nil { 491 - return handleErr 492 - } 493 - return nil 494 - } 495 - 496 - func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error { 497 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset") 498 - defer span.End() 499 - 500 - var body comatprototypes.AccountRequestPasswordReset_Input 501 - if err := c.Bind(&body); err != nil { 502 - return err 503 - } 504 - var handleErr error 505 - // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error 506 - handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body) 507 - if handleErr != nil { 508 - return handleErr 509 - } 510 - return nil 511 - } 512 - 513 - func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error { 514 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword") 515 - defer span.End() 516 - 517 - var body comatprototypes.AccountResetPassword_Input 518 - if err := c.Bind(&body); err != nil { 519 - return err 520 - } 521 - var handleErr error 522 - // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error 523 - handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body) 524 - if handleErr != nil { 525 - return handleErr 526 - } 527 - return nil 528 - } 529 - 530 - func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error { 531 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve") 532 - defer span.End() 533 - handle := c.QueryParam("handle") 534 - var out *comatprototypes.HandleResolve_Output 535 - var handleErr error 536 - // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error) 537 - out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle) 538 - if handleErr != nil { 539 - return handleErr 540 - } 541 - return c.JSON(200, out) 542 - } 543 - 544 - func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error { 545 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite") 546 - defer span.End() 547 - 548 - var body comatprototypes.RepoBatchWrite_Input 549 - if err := c.Bind(&body); err != nil { 550 - return err 551 - } 552 - var handleErr error 553 - // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error 554 - handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body) 555 - if handleErr != nil { 556 - return handleErr 557 - } 558 - return nil 559 - } 560 - 561 - func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error { 562 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord") 563 - defer span.End() 564 - 565 - var body comatprototypes.RepoCreateRecord_Input 566 - if err := c.Bind(&body); err != nil { 567 - return err 568 - } 569 - var out *comatprototypes.RepoCreateRecord_Output 570 - var handleErr error 571 - // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error) 572 - out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body) 573 - if handleErr != nil { 574 - return handleErr 575 - } 576 - return c.JSON(200, out) 577 - } 578 - 579 - func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error { 580 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord") 581 - defer span.End() 582 - 583 - var body comatprototypes.RepoDeleteRecord_Input 584 - if err := c.Bind(&body); err != nil { 585 - return err 586 - } 587 - var handleErr error 588 - // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error 589 - handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body) 590 - if handleErr != nil { 591 - return handleErr 592 - } 593 - return nil 594 - } 595 - 596 - func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error { 597 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe") 598 - defer span.End() 599 - user := c.QueryParam("user") 600 - var out *comatprototypes.RepoDescribe_Output 601 - var handleErr error 602 - // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error) 603 - out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user) 604 - if handleErr != nil { 605 - return handleErr 606 - } 607 - return c.JSON(200, out) 608 - } 609 - 610 - func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 611 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 612 - defer span.End() 613 - cid := c.QueryParam("cid") 614 - collection := c.QueryParam("collection") 615 - rkey := c.QueryParam("rkey") 616 - user := c.QueryParam("user") 617 - var out *comatprototypes.RepoGetRecord_Output 618 - var handleErr error 619 - // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error) 620 - out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user) 621 - if handleErr != nil { 622 - return handleErr 623 - } 624 - return c.JSON(200, out) 625 - } 626 - 627 - func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 628 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 629 - defer span.End() 630 - after := c.QueryParam("after") 631 - before := c.QueryParam("before") 632 - collection := c.QueryParam("collection") 633 - 634 - limit, err := strconv.Atoi(c.QueryParam("limit")) 635 - if err != nil { 636 - return err 637 - } 638 - var out *comatprototypes.RepoListRecords_Output 639 - var handleErr error 640 - // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error) 641 - out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit) 642 - if handleErr != nil { 643 - return handleErr 644 - } 645 - return c.JSON(200, out) 646 - } 647 - 648 - func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error { 649 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord") 650 - defer span.End() 651 - 652 - var body comatprototypes.RepoPutRecord_Input 653 - if err := c.Bind(&body); err != nil { 654 - return err 655 - } 656 - var out *comatprototypes.RepoPutRecord_Output 657 - var handleErr error 658 - // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error) 659 - out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body) 660 - if handleErr != nil { 661 - return handleErr 662 - } 663 - return c.JSON(200, out) 664 - } 665 - 666 - func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 667 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 668 - defer span.End() 669 - var out *comatprototypes.ServerGetAccountsConfig_Output 670 - var handleErr error 671 - // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) 672 - out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 673 - if handleErr != nil { 674 - return handleErr 675 - } 676 - return c.JSON(200, out) 677 - } 678 - 679 - func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error { 680 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate") 681 - defer span.End() 682 - 683 - var body comatprototypes.SessionCreate_Input 684 - if err := c.Bind(&body); err != nil { 685 - return err 686 - } 687 - var out *comatprototypes.SessionCreate_Output 688 - var handleErr error 689 - // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) 690 - out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body) 691 - if handleErr != nil { 692 - return handleErr 693 - } 694 - return c.JSON(200, out) 695 - } 696 - 697 - func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error { 698 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete") 699 - defer span.End() 700 - var handleErr error 701 - // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error 702 - handleErr = s.handleComAtprotoSessionDelete(ctx) 703 - if handleErr != nil { 704 - return handleErr 705 - } 706 - return nil 707 - } 708 - 709 - func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error { 710 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet") 711 - defer span.End() 712 - var out *comatprototypes.SessionGet_Output 713 - var handleErr error 714 - // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error) 715 - out, handleErr = s.handleComAtprotoSessionGet(ctx) 716 - if handleErr != nil { 717 - return handleErr 718 - } 719 - return c.JSON(200, out) 720 - } 721 - 722 - func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error { 723 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh") 724 - defer span.End() 725 - var out *comatprototypes.SessionRefresh_Output 726 - var handleErr error 727 - // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error) 728 - out, handleErr = s.handleComAtprotoSessionRefresh(ctx) 729 - if handleErr != nil { 730 - return handleErr 731 - } 732 - return c.JSON(200, out) 733 - } 734 - 735 - func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 736 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 737 - defer span.End() 738 - did := c.QueryParam("did") 739 - from := c.QueryParam("from") 740 - var out io.Reader 741 - var handleErr error 742 - // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 743 - out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 744 - if handleErr != nil { 745 - return handleErr 746 - } 747 - 748 - return c.Stream(200, "application/octet-stream", out) 749 - } 750 - 751 - func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error { 752 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot") 753 - defer span.End() 754 - did := c.QueryParam("did") 755 - var out *comatprototypes.SyncGetRoot_Output 756 - var handleErr error 757 - // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error) 758 - out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did) 759 - if handleErr != nil { 760 - return handleErr 761 - } 762 - return c.JSON(200, out) 763 - } 764 - 765 - func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error { 766 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo") 767 - defer span.End() 768 - body := c.Request().Body 769 - var handleErr error 770 - // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error 771 - handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body) 772 - if handleErr != nil { 773 - return handleErr 774 - } 775 - return nil 776 - }
+36 -6
carstore/bs.go
··· 206 206 } 207 207 208 208 type DeltaSession struct { 209 - fresh blockstore.Blockstore 210 - blks map[cid.Cid]blocks.Block 211 - base blockstore.Blockstore 212 - user uint 213 - seq int 214 - cs *CarStore 209 + fresh blockstore.Blockstore 210 + blks map[cid.Cid]blocks.Block 211 + base blockstore.Blockstore 212 + user uint 213 + seq int 214 + readonly bool 215 + cs *CarStore 215 216 } 216 217 217 218 func (cs *CarStore) NewDeltaSession(user uint, prev cid.Cid) (*DeltaSession, error) { ··· 244 245 }, nil 245 246 } 246 247 248 + func (cs *CarStore) ReadOnlySession(user uint) (*DeltaSession, error) { 249 + return &DeltaSession{ 250 + base: &userView{ 251 + user: user, 252 + cs: cs, 253 + prefetch: false, 254 + cache: make(map[cid.Cid]blocks.Block), 255 + }, 256 + readonly: true, 257 + user: user, 258 + cs: cs, 259 + }, nil 260 + } 261 + 247 262 func (cs *CarStore) ReadUserCar(ctx context.Context, user uint, until cid.Cid, incremental bool, w io.Writer) error { 248 263 var untilSeq int 249 264 ··· 313 328 var _ blockstore.Blockstore = (*DeltaSession)(nil) 314 329 315 330 func (ds *DeltaSession) Put(ctx context.Context, b blocks.Block) error { 331 + if ds.readonly { 332 + return fmt.Errorf("cannot write to readonly deltaSession") 333 + } 316 334 ds.blks[b.Cid()] = b 317 335 return nil 318 336 } 319 337 320 338 func (ds *DeltaSession) PutMany(ctx context.Context, bs []blocks.Block) error { 339 + if ds.readonly { 340 + return fmt.Errorf("cannot write to readonly deltaSession") 341 + } 342 + 321 343 for _, b := range bs { 322 344 ds.blks[b.Cid()] = b 323 345 } ··· 329 351 } 330 352 331 353 func (ds *DeltaSession) DeleteBlock(ctx context.Context, c cid.Cid) error { 354 + if ds.readonly { 355 + return fmt.Errorf("cannot write to readonly deltaSession") 356 + } 357 + 332 358 if _, ok := ds.blks[c]; !ok { 333 359 return ipld.ErrNotFound{c} 334 360 } ··· 382 408 // CloseWithRoot writes all new blocks in a car file to the writer with the 383 409 // given cid as the 'root' 384 410 func (ds *DeltaSession) CloseWithRoot(ctx context.Context, root cid.Cid) error { 411 + if ds.readonly { 412 + return fmt.Errorf("cannot write to readonly deltaSession") 413 + } 414 + 385 415 fi, path, err := ds.cs.openNewShardFile(ctx, ds.user, ds.seq) 386 416 if err != nil { 387 417 return err
+5
gen/main.go
··· 5 5 "github.com/whyrusleeping/gosky/api" 6 6 atproto "github.com/whyrusleeping/gosky/api/atproto" 7 7 bsky "github.com/whyrusleeping/gosky/api/bsky" 8 + "github.com/whyrusleeping/gosky/lex/util" 8 9 mst "github.com/whyrusleeping/gosky/mst" 9 10 "github.com/whyrusleeping/gosky/repo" 10 11 ) ··· 37 38 } 38 39 39 40 if err := cbg.WriteMapEncodersToFile("api/atproto/cbor_gen.go", "schemagen", atproto.RepoStrongRef{}); err != nil { 41 + panic(err) 42 + } 43 + 44 + if err := cbg.WriteMapEncodersToFile("lex/util/cbor_gen.go", "util", util.CborChecker{}); err != nil { 40 45 panic(err) 41 46 } 42 47 }
+1 -1
go.mod
··· 19 19 github.com/lestrrat-go/jwx v1.2.25 20 20 github.com/multiformats/go-multihash v0.1.0 21 21 github.com/urfave/cli/v2 v2.23.0 22 - github.com/whyrusleeping/cbor-gen v0.0.0-20221120232258-33755d0abe95 22 + github.com/whyrusleeping/cbor-gen v0.0.0-20221213005056-dae902347b80 23 23 github.com/whyrusleeping/go-did v0.0.0-20221105001742-8d9e0ffb0d59 24 24 go.opentelemetry.io/otel v0.20.0 25 25 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
+2
go.sum
··· 948 948 github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= 949 949 github.com/whyrusleeping/cbor-gen v0.0.0-20221120232258-33755d0abe95 h1:f4dFX0UniZ3T3TswZsQJ82hJUII2cQOcNVZsMTxus3g= 950 950 github.com/whyrusleeping/cbor-gen v0.0.0-20221120232258-33755d0abe95/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= 951 + github.com/whyrusleeping/cbor-gen v0.0.0-20221213005056-dae902347b80 h1:gPPteVCBO6iLrtSZtVjOGe5n+2e+Hy6vN+o+4NLvx5g= 952 + github.com/whyrusleeping/cbor-gen v0.0.0-20221213005056-dae902347b80/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= 951 953 github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= 952 954 github.com/whyrusleeping/go-did v0.0.0-20221105001742-8d9e0ffb0d59 h1:dRYr/sfpZjX8evmbFrOG7ldkzdk5TLMGRVM40k1AZPQ= 953 955 github.com/whyrusleeping/go-did v0.0.0-20221105001742-8d9e0ffb0d59/go.mod h1:mX/AQ/SS9KrCwO8V+IWyIozytxw5gw75cMHymoJvMGo=
+68 -3
lex/gen.go
··· 185 185 if k != "main" { 186 186 n = s.ID + "#" + k 187 187 } 188 - fmt.Println("def map: ", n) 189 188 out[n] = &ExtDef{ 190 189 Type: d, 191 190 } ··· 224 223 225 224 tps := s.AllTypes(prefix, defmap) 226 225 226 + if err := writeDecoderRegister(buf, tps); err != nil { 227 + return err 228 + } 229 + 227 230 for _, ot := range tps { 228 231 fmt.Println("TYPE: ", ot.Name) 229 232 if err := ot.Type.WriteType(ot.Name, buf); err != nil { ··· 241 244 if err := writeCodeFile(buf.Bytes(), fname); err != nil { 242 245 return err 243 246 } 247 + 248 + return nil 249 + } 250 + 251 + func writeDecoderRegister(w io.Writer, tps []outputType) error { 252 + fmt.Fprintln(w, "func init() {") 253 + for _, t := range tps { 254 + 255 + if t.Type.record && !strings.Contains(t.Name, "_") { 256 + id := t.Type.id 257 + if t.Type.defName != "" { 258 + id = id + "#" + t.Type.defName 259 + } 260 + fmt.Fprintf(w, "util.RegisterType(%q, %s{})\n", id, t.Name) 261 + } 262 + } 263 + fmt.Fprintln(w, "}") 244 264 245 265 return nil 246 266 } ··· 663 683 fmt.Fprintf(w, "ctx, span := otel.Tracer(\"server\").Start(c.Request().Context(), %q)\n", "Handle"+fname) 664 684 fmt.Fprintf(w, "defer span.End()\n") 665 685 686 + var required map[string]bool 687 + if s.Required != nil { 688 + for _, r := range s.Required { 689 + required[r] = true 690 + } 691 + } 692 + 666 693 paramtypes := []string{"ctx context.Context"} 667 694 params := []string{"ctx"} 668 695 if s.Type == "query" { ··· 675 702 fmt.Fprintf(w, "%s := c.QueryParam(\"%s\")\n", k, k) 676 703 case "integer": 677 704 params = append(params, k) 705 + 706 + if required != nil && !required[k] { 707 + paramtypes = append(paramtypes, k+" *int") 708 + fmt.Fprintf(w, ` 709 + var %s *int 710 + if p := c.QueryParam("%s"); p != "" { 711 + %s_val, err := strconv.Atoi(p) 712 + if err != nil { 713 + return err 714 + } 715 + %s = &%s_val 716 + } 717 + `, k, k, k, k, k) 718 + } else { 678 719 paramtypes = append(paramtypes, k+" int") 679 720 fmt.Fprintf(w, ` 680 721 %s, err := strconv.Atoi(c.QueryParam("%s")) ··· 682 723 return err 683 724 } 684 725 `, k, k) 726 + } 727 + 728 + 685 729 case "number": 686 730 return fmt.Errorf("non-integer numbers currently unsupported") 687 731 default: ··· 870 914 871 915 fmt.Fprintf(w, "type %s struct {\n", name) 872 916 917 + if ts.record { 918 + fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type\" cborgen:\"$type,const=%s\"`\n", ts.id) 919 + } 920 + 921 + var required map[string]bool 922 + if ts.Required != nil { 923 + required = make(map[string]bool) 924 + for _, req := range ts.Required { 925 + required[req] = true 926 + } 927 + } 928 + 873 929 for k, v := range ts.Properties { 874 930 goname := strings.Title(k) 875 931 ··· 878 934 return err 879 935 } 880 936 881 - fmt.Fprintf(w, "\t%s %s `json:\"%s\" cborgen:\"%s\"`\n", goname, tname, k, k) 937 + var ptr string 938 + if required != nil && !required[k] { 939 + if !strings.HasPrefix(tname, "*") && !strings.HasPrefix(tname, "[]") { 940 + ptr = "*" 941 + } 942 + } 943 + 944 + fmt.Fprintf(w, "\t%s %s%s `json:\"%s\" cborgen:\"%s\"`\n", goname, ptr, tname, k, k) 882 945 883 946 } 884 947 fmt.Fprintf(w, "}\n\n") ··· 968 1031 } 969 1032 970 1033 func (ts *TypeSchema) writeJsonMarshalerObject(name string, w io.Writer) error { 1034 + return nil // no need for a special json marshaler right now 1035 + 971 1036 if len(ts.Properties) == 0 { 972 1037 // TODO: this is a hacky special casing of record types... 973 1038 return nil ··· 1042 1107 1043 1108 func (ts *TypeSchema) writeJsonUnmarshalerEnum(name string, w io.Writer) error { 1044 1109 fmt.Fprintf(w, "func (t *%s) UnmarshalJSON(b []byte) (error) {\n", name) 1045 - fmt.Fprintf(w, "\ttyp, err := util.EnumTypeExtract(b)\n") 1110 + fmt.Fprintf(w, "\ttyp, err := util.TypeExtract(b)\n") 1046 1111 fmt.Fprintf(w, "\tif err != nil {\n\t\treturn err\n\t}\n\n") 1047 1112 fmt.Fprintf(w, "\tswitch typ {\n") 1048 1113 for _, e := range ts.Refs {
+15 -1
lex/util/util.go
··· 1 1 package util 2 2 3 3 import ( 4 + "bytes" 4 5 "encoding/json" 5 6 ) 6 7 ··· 8 9 Type string `json:"$type"` 9 10 } 10 11 11 - func EnumTypeExtract(b []byte) (string, error) { 12 + func TypeExtract(b []byte) (string, error) { 12 13 var te typeExtractor 13 14 if err := json.Unmarshal(b, &te); err != nil { 14 15 return "", err ··· 21 22 Cid string `json:"cid"` 22 23 MimeType string `json:"mimeType"` 23 24 } 25 + 26 + type CborChecker struct { 27 + Type string `cborgen:"$type"` 28 + } 29 + 30 + func CborTypeExtract(b []byte) (string, error) { 31 + var tcheck CborChecker 32 + if err := tcheck.UnmarshalCBOR(bytes.NewReader(b)); err != nil { 33 + return "", err 34 + } 35 + 36 + return tcheck.Type, nil 37 + }
+3 -3
repo/cbor_gen.go
··· 338 338 } 339 339 340 340 cw := cbg.NewCborWriter(w) 341 - var emptyFieldCount int 341 + fieldCount := 4 342 342 343 343 if t.Prev == nil { 344 - emptyFieldCount++ 344 + fieldCount-- 345 345 } 346 346 347 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(4-emptyFieldCount))); err != nil { 347 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 348 348 return err 349 349 } 350 350
+25
repo/repo.go
··· 10 10 blockstore "github.com/ipfs/go-ipfs-blockstore" 11 11 cbor "github.com/ipfs/go-ipld-cbor" 12 12 "github.com/ipld/go-car/v2" 13 + "github.com/whyrusleeping/gosky/lex/util" 13 14 "github.com/whyrusleeping/gosky/mst" 14 15 ) 15 16 ··· 216 217 } 217 218 218 219 return nil 220 + } 221 + 222 + func (r *Repo) GetRecord(ctx context.Context, tid string) (cid.Cid, any, error) { 223 + mst, err := r.getMst(ctx) 224 + if err != nil { 225 + return cid.Undef, nil, err 226 + } 227 + 228 + cc, err := mst.Get(ctx, tid) 229 + if err != nil { 230 + return cid.Undef, nil, err 231 + } 232 + 233 + blk, err := r.bs.Get(ctx, cc) 234 + if err != nil { 235 + return cid.Undef, nil, err 236 + } 237 + 238 + rec, err := util.CborDecodeValue(blk.RawData()) 239 + if err != nil { 240 + return cid.Undef, nil, err 241 + } 242 + 243 + return cc, rec, nil 219 244 } 220 245 221 246 func (r *Repo) DiffSince(ctx context.Context, oldrepo cid.Cid) ([]*mst.DiffOp, error) {
+38 -2
repomgr/repomgr.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "fmt" 5 6 "io" 6 7 "sync" 7 8 ··· 116 117 117 118 func (rm *RepoManager) CreateRecord(ctx context.Context, user uint, collection string, rec cbg.CBORMarshaler) (string, cid.Cid, error) { 118 119 ntid := repo.NextTID() 120 + rkey := collection + "/" + ntid 119 121 120 122 unlock := rm.lockUser(user) 121 123 defer unlock() 122 - 123 - rkey := collection + "/" + ntid 124 124 125 125 head, err := rm.getUserRepoHead(ctx, user) 126 126 if err != nil { ··· 176 176 unlock := rm.lockUser(user) 177 177 defer unlock() 178 178 179 + if did == "" { 180 + return fmt.Errorf("must specify did for new actor") 181 + } 182 + 183 + if user == 0 { 184 + return fmt.Errorf("must specify unique non-zero id for new actor") 185 + } 186 + 179 187 ds, err := rm.cs.NewDeltaSession(user, cid.Undef) 180 188 if err != nil { 181 189 return err ··· 230 238 func (rm *RepoManager) ReadRepo(ctx context.Context, user uint, fromcid cid.Cid, w io.Writer) error { 231 239 return rm.cs.ReadUserCar(ctx, user, fromcid, true, w) 232 240 } 241 + 242 + func (rm *RepoManager) GetRecord(ctx context.Context, user uint, collection string, rkey string, maybeCid cid.Cid) (cid.Cid, any, error) { 243 + bs, err := rm.cs.ReadOnlySession(user) 244 + if err != nil { 245 + return cid.Undef, nil, err 246 + } 247 + 248 + head, err := rm.getUserRepoHead(ctx, user) 249 + if err != nil { 250 + return cid.Undef, nil, err 251 + } 252 + 253 + r, err := repo.OpenRepo(ctx, bs, head) 254 + if err != nil { 255 + return cid.Undef, nil, err 256 + } 257 + 258 + ocid, val, err := r.GetRecord(ctx, collection+"/"+rkey) 259 + if err != nil { 260 + return cid.Undef, nil, err 261 + } 262 + 263 + if maybeCid.Defined() && ocid != maybeCid { 264 + return cid.Undef, nil, fmt.Errorf("record at specified key had different CID than expected") 265 + } 266 + 267 + return ocid, val, nil 268 + }
+8
testscripts/pdstest.sh
··· 1 1 #!/bin/bash 2 2 set -e 3 3 set -x 4 + 5 + echo "1. Creating Account" 4 6 ./gosky --pds="http://localhost:4989" newAccount test@foo.com testman.pdstest password > test.auth 7 + 8 + echo "2. Some Content" 5 9 ./gosky --pds="http://localhost:4989" --auth="test.auth" post "cats are really cool and the best" 6 10 ./gosky --pds="http://localhost:4989" --auth="test.auth" post "paul frazee needs to buy a sweater" 7 11 12 + echo "3. View That Content" 13 + ./gosky --pds="http://localhost:4989" --auth="test.auth" getAuthorFeed 14 + 15 +