this repo has no description
0
fork

Configure Feed

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

more pds server work, dealing with updated lexicon files

why 81b2cecc 94deb833

+2498 -514
+9 -9
api/atproto/accountcreate.go
··· 10 10 // schema: com.atproto.account.create 11 11 12 12 type AccountCreate_Input struct { 13 - Email string `json:"email"` 14 - Handle string `json:"handle"` 15 - InviteCode string `json:"inviteCode"` 16 - Password string `json:"password"` 17 - RecoveryKey string `json:"recoveryKey"` 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"` 18 18 } 19 19 20 20 func (t *AccountCreate_Input) MarshalJSON() ([]byte, error) { ··· 28 28 } 29 29 30 30 type AccountCreate_Output struct { 31 - Handle string `json:"handle"` 32 - Did string `json:"did"` 33 - AccessJwt string `json:"accessJwt"` 34 - RefreshJwt string `json:"refreshJwt"` 31 + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 32 + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 33 + Handle string `json:"handle" cborgen:"handle"` 34 + Did string `json:"did" cborgen:"did"` 35 35 } 36 36 37 37 func (t *AccountCreate_Output) MarshalJSON() ([]byte, error) {
+2 -2
api/atproto/accountcreateInviteCode.go
··· 10 10 // schema: com.atproto.account.createInviteCode 11 11 12 12 type AccountCreateInviteCode_Input struct { 13 - UseCount int64 `json:"useCount"` 13 + UseCount int64 `json:"useCount" cborgen:"useCount"` 14 14 } 15 15 16 16 func (t *AccountCreateInviteCode_Input) MarshalJSON() ([]byte, error) { ··· 20 20 } 21 21 22 22 type AccountCreateInviteCode_Output struct { 23 - Code string `json:"code"` 23 + Code string `json:"code" cborgen:"code"` 24 24 } 25 25 26 26 func (t *AccountCreateInviteCode_Output) MarshalJSON() ([]byte, error) {
+1 -1
api/atproto/accountrequestPasswordReset.go
··· 10 10 // schema: com.atproto.account.requestPasswordReset 11 11 12 12 type AccountRequestPasswordReset_Input struct { 13 - Email string `json:"email"` 13 + Email string `json:"email" cborgen:"email"` 14 14 } 15 15 16 16 func (t *AccountRequestPasswordReset_Input) MarshalJSON() ([]byte, error) {
+2 -2
api/atproto/accountresetPassword.go
··· 10 10 // schema: com.atproto.account.resetPassword 11 11 12 12 type AccountResetPassword_Input struct { 13 - Password string `json:"password"` 14 - Token string `json:"token"` 13 + Token string `json:"token" cborgen:"token"` 14 + Password string `json:"password" cborgen:"password"` 15 15 } 16 16 17 17 func (t *AccountResetPassword_Input) MarshalJSON() ([]byte, error) {
+149
api/atproto/cbor_gen.go
··· 1 + // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 + 3 + package schemagen 4 + 5 + import ( 6 + "fmt" 7 + "io" 8 + "math" 9 + "sort" 10 + 11 + cid "github.com/ipfs/go-cid" 12 + cbg "github.com/whyrusleeping/cbor-gen" 13 + xerrors "golang.org/x/xerrors" 14 + ) 15 + 16 + var _ = xerrors.Errorf 17 + var _ = cid.Undef 18 + var _ = math.E 19 + var _ = sort.Sort 20 + 21 + func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { 22 + if t == nil { 23 + _, err := w.Write(cbg.CborNull) 24 + return err 25 + } 26 + 27 + cw := cbg.NewCborWriter(w) 28 + 29 + if _, err := cw.Write([]byte{162}); err != nil { 30 + return err 31 + } 32 + 33 + // t.Uri (string) (string) 34 + if len("uri") > cbg.MaxLength { 35 + return xerrors.Errorf("Value in field \"uri\" was too long") 36 + } 37 + 38 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("uri"))); err != nil { 39 + return err 40 + } 41 + if _, err := io.WriteString(w, string("uri")); err != nil { 42 + return err 43 + } 44 + 45 + if len(t.Uri) > cbg.MaxLength { 46 + return xerrors.Errorf("Value in field t.Uri was too long") 47 + } 48 + 49 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Uri))); err != nil { 50 + return err 51 + } 52 + if _, err := io.WriteString(w, string(t.Uri)); err != nil { 53 + return err 54 + } 55 + 56 + // t.Cid (string) (string) 57 + if len("cid") > cbg.MaxLength { 58 + return xerrors.Errorf("Value in field \"cid\" was too long") 59 + } 60 + 61 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("cid"))); err != nil { 62 + return err 63 + } 64 + if _, err := io.WriteString(w, string("cid")); err != nil { 65 + return err 66 + } 67 + 68 + if len(t.Cid) > cbg.MaxLength { 69 + return xerrors.Errorf("Value in field t.Cid was too long") 70 + } 71 + 72 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Cid))); err != nil { 73 + return err 74 + } 75 + if _, err := io.WriteString(w, string(t.Cid)); err != nil { 76 + return err 77 + } 78 + return nil 79 + } 80 + 81 + func (t *RepoStrongRef) UnmarshalCBOR(r io.Reader) (err error) { 82 + *t = RepoStrongRef{} 83 + 84 + cr := cbg.NewCborReader(r) 85 + 86 + maj, extra, err := cr.ReadHeader() 87 + if err != nil { 88 + return err 89 + } 90 + defer func() { 91 + if err == io.EOF { 92 + err = io.ErrUnexpectedEOF 93 + } 94 + }() 95 + 96 + if maj != cbg.MajMap { 97 + return fmt.Errorf("cbor input should be of type map") 98 + } 99 + 100 + if extra > cbg.MaxLength { 101 + return fmt.Errorf("RepoStrongRef: map struct too large (%d)", extra) 102 + } 103 + 104 + var name string 105 + n := extra 106 + 107 + for i := uint64(0); i < n; i++ { 108 + 109 + { 110 + sval, err := cbg.ReadString(cr) 111 + if err != nil { 112 + return err 113 + } 114 + 115 + name = string(sval) 116 + } 117 + 118 + switch name { 119 + // t.Uri (string) (string) 120 + case "uri": 121 + 122 + { 123 + sval, err := cbg.ReadString(cr) 124 + if err != nil { 125 + return err 126 + } 127 + 128 + t.Uri = string(sval) 129 + } 130 + // t.Cid (string) (string) 131 + case "cid": 132 + 133 + { 134 + sval, err := cbg.ReadString(cr) 135 + if err != nil { 136 + return err 137 + } 138 + 139 + t.Cid = string(sval) 140 + } 141 + 142 + default: 143 + // Field doesn't exist on this type, so ignore it 144 + cbg.ScanForLinks(r, func(cid.Cid) {}) 145 + } 146 + } 147 + 148 + return nil 149 + }
+1 -1
api/atproto/handleresolve.go
··· 10 10 // schema: com.atproto.handle.resolve 11 11 12 12 type HandleResolve_Output struct { 13 - Did string `json:"did"` 13 + Did string `json:"did" cborgen:"did"` 14 14 } 15 15 16 16 func (t *HandleResolve_Output) MarshalJSON() ([]byte, error) {
+26 -26
api/atproto/repobatchWrite.go
··· 11 11 12 12 // schema: com.atproto.repo.batchWrite 13 13 14 - type RepoBatchWrite_Delete struct { 15 - Action string `json:"action"` 16 - Collection string `json:"collection"` 17 - Rkey string `json:"rkey"` 18 - } 19 - 20 - func (t *RepoBatchWrite_Delete) MarshalJSON() ([]byte, error) { 21 - t.Action = "delete" 22 - out := make(map[string]interface{}) 23 - out["action"] = t.Action 24 - out["collection"] = t.Collection 25 - out["rkey"] = t.Rkey 26 - return json.Marshal(out) 27 - } 28 - 29 14 type RepoBatchWrite_Input struct { 30 - Did string `json:"did"` 31 - Validate bool `json:"validate"` 32 - Writes []*RepoBatchWrite_Input_Writes_Elem `json:"writes"` 15 + Validate bool `json:"validate" cborgen:"validate"` 16 + Writes []*RepoBatchWrite_Input_Writes_Elem `json:"writes" cborgen:"writes"` 17 + Did string `json:"did" cborgen:"did"` 33 18 } 34 19 35 20 func (t *RepoBatchWrite_Input) MarshalJSON() ([]byte, error) { ··· 81 66 } 82 67 83 68 type RepoBatchWrite_Create struct { 84 - Action string `json:"action"` 85 - Collection string `json:"collection"` 86 - Rkey string `json:"rkey"` 87 - Value any `json:"value"` 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"` 88 73 } 89 74 90 75 func (t *RepoBatchWrite_Create) MarshalJSON() ([]byte, error) { ··· 98 83 } 99 84 100 85 type RepoBatchWrite_Update struct { 101 - Action string `json:"action"` 102 - Collection string `json:"collection"` 103 - Rkey string `json:"rkey"` 104 - Value any `json:"value"` 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"` 105 90 } 106 91 107 92 func (t *RepoBatchWrite_Update) MarshalJSON() ([]byte, error) { ··· 111 96 out["collection"] = t.Collection 112 97 out["rkey"] = t.Rkey 113 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 114 return json.Marshal(out) 115 115 } 116 116
+6 -6
api/atproto/repocreateRecord.go
··· 10 10 // schema: com.atproto.repo.createRecord 11 11 12 12 type RepoCreateRecord_Input struct { 13 - Did string `json:"did"` 14 - Collection string `json:"collection"` 15 - Validate bool `json:"validate"` 16 - Record any `json:"record"` 13 + Did string `json:"did" cborgen:"did"` 14 + Collection string `json:"collection" cborgen:"collection"` 15 + Validate bool `json:"validate" cborgen:"validate"` 16 + Record any `json:"record" cborgen:"record"` 17 17 } 18 18 19 19 func (t *RepoCreateRecord_Input) MarshalJSON() ([]byte, error) { ··· 26 26 } 27 27 28 28 type RepoCreateRecord_Output struct { 29 - Uri string `json:"uri"` 30 - Cid string `json:"cid"` 29 + Uri string `json:"uri" cborgen:"uri"` 30 + Cid string `json:"cid" cborgen:"cid"` 31 31 } 32 32 33 33 func (t *RepoCreateRecord_Output) MarshalJSON() ([]byte, error) {
+3 -3
api/atproto/repodeleteRecord.go
··· 10 10 // schema: com.atproto.repo.deleteRecord 11 11 12 12 type RepoDeleteRecord_Input struct { 13 - Rkey string `json:"rkey"` 14 - Did string `json:"did"` 15 - Collection string `json:"collection"` 13 + Collection string `json:"collection" cborgen:"collection"` 14 + Rkey string `json:"rkey" cborgen:"rkey"` 15 + Did string `json:"did" cborgen:"did"` 16 16 } 17 17 18 18 func (t *RepoDeleteRecord_Input) MarshalJSON() ([]byte, error) {
+5 -5
api/atproto/repodescribe.go
··· 10 10 // schema: com.atproto.repo.describe 11 11 12 12 type RepoDescribe_Output struct { 13 - Handle string `json:"handle"` 14 - Did string `json:"did"` 15 - DidDoc any `json:"didDoc"` 16 - Collections []string `json:"collections"` 17 - HandleIsCorrect bool `json:"handleIsCorrect"` 13 + Handle string `json:"handle" cborgen:"handle"` 14 + Did string `json:"did" cborgen:"did"` 15 + DidDoc any `json:"didDoc" cborgen:"didDoc"` 16 + Collections []string `json:"collections" cborgen:"collections"` 17 + HandleIsCorrect bool `json:"handleIsCorrect" cborgen:"handleIsCorrect"` 18 18 } 19 19 20 20 func (t *RepoDescribe_Output) MarshalJSON() ([]byte, error) {
+3 -3
api/atproto/repogetRecord.go
··· 10 10 // schema: com.atproto.repo.getRecord 11 11 12 12 type RepoGetRecord_Output struct { 13 - Uri string `json:"uri"` 14 - Cid string `json:"cid"` 15 - Value any `json:"value"` 13 + Value any `json:"value" cborgen:"value"` 14 + Uri string `json:"uri" cborgen:"uri"` 15 + Cid string `json:"cid" cborgen:"cid"` 16 16 } 17 17 18 18 func (t *RepoGetRecord_Output) MarshalJSON() ([]byte, error) {
+5 -5
api/atproto/repolistRecords.go
··· 10 10 // schema: com.atproto.repo.listRecords 11 11 12 12 type RepoListRecords_Output struct { 13 - Cursor string `json:"cursor"` 14 - Records []*RepoListRecords_Record `json:"records"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Records []*RepoListRecords_Record `json:"records" cborgen:"records"` 15 15 } 16 16 17 17 func (t *RepoListRecords_Output) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type RepoListRecords_Record struct { 25 - Uri string `json:"uri"` 26 - Cid string `json:"cid"` 27 - Value any `json:"value"` 25 + Value any `json:"value" cborgen:"value"` 26 + Uri string `json:"uri" cborgen:"uri"` 27 + Cid string `json:"cid" cborgen:"cid"` 28 28 } 29 29 30 30 func (t *RepoListRecords_Record) MarshalJSON() ([]byte, error) {
+7 -7
api/atproto/repoputRecord.go
··· 10 10 // schema: com.atproto.repo.putRecord 11 11 12 12 type RepoPutRecord_Input struct { 13 - Did string `json:"did"` 14 - Collection string `json:"collection"` 15 - Rkey string `json:"rkey"` 16 - Validate bool `json:"validate"` 17 - Record any `json:"record"` 13 + Rkey string `json:"rkey" cborgen:"rkey"` 14 + Validate bool `json:"validate" cborgen:"validate"` 15 + Record any `json:"record" cborgen:"record"` 16 + Did string `json:"did" cborgen:"did"` 17 + Collection string `json:"collection" cborgen:"collection"` 18 18 } 19 19 20 20 func (t *RepoPutRecord_Input) MarshalJSON() ([]byte, error) { ··· 28 28 } 29 29 30 30 type RepoPutRecord_Output struct { 31 - Uri string `json:"uri"` 32 - Cid string `json:"cid"` 31 + Uri string `json:"uri" cborgen:"uri"` 32 + Cid string `json:"cid" cborgen:"cid"` 33 33 } 34 34 35 35 func (t *RepoPutRecord_Output) MarshalJSON() ([]byte, error) {
+2 -2
api/atproto/repostrongRef.go
··· 7 7 // schema: com.atproto.repo.strongRef 8 8 9 9 type RepoStrongRef struct { 10 - Uri string `json:"uri"` 11 - Cid string `json:"cid"` 10 + Uri string `json:"uri" cborgen:"uri"` 11 + Cid string `json:"cid" cborgen:"cid"` 12 12 } 13 13 14 14 func (t *RepoStrongRef) MarshalJSON() ([]byte, error) {
+16 -2
api/atproto/servergetAccountsConfig.go
··· 10 10 // schema: com.atproto.server.getAccountsConfig 11 11 12 12 type ServerGetAccountsConfig_Output struct { 13 - InviteCodeRequired bool `json:"inviteCodeRequired"` 14 - AvailableUserDomains []string `json:"availableUserDomains"` 13 + InviteCodeRequired bool `json:"inviteCodeRequired" cborgen:"inviteCodeRequired"` 14 + AvailableUserDomains []string `json:"availableUserDomains" cborgen:"availableUserDomains"` 15 + Links *ServerGetAccountsConfig_Links `json:"links" cborgen:"links"` 15 16 } 16 17 17 18 func (t *ServerGetAccountsConfig_Output) MarshalJSON() ([]byte, error) { 18 19 out := make(map[string]interface{}) 19 20 out["availableUserDomains"] = t.AvailableUserDomains 20 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 21 35 return json.Marshal(out) 22 36 } 23 37
+6 -6
api/atproto/sessioncreate.go
··· 10 10 // schema: com.atproto.session.create 11 11 12 12 type SessionCreate_Input struct { 13 - Handle string `json:"handle"` 14 - Password string `json:"password"` 13 + Handle string `json:"handle" cborgen:"handle"` 14 + Password string `json:"password" cborgen:"password"` 15 15 } 16 16 17 17 func (t *SessionCreate_Input) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type SessionCreate_Output struct { 25 - AccessJwt string `json:"accessJwt"` 26 - RefreshJwt string `json:"refreshJwt"` 27 - Handle string `json:"handle"` 28 - Did string `json:"did"` 25 + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 26 + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 27 + Handle string `json:"handle" cborgen:"handle"` 28 + Did string `json:"did" cborgen:"did"` 29 29 } 30 30 31 31 func (t *SessionCreate_Output) MarshalJSON() ([]byte, error) {
+2 -2
api/atproto/sessionget.go
··· 10 10 // schema: com.atproto.session.get 11 11 12 12 type SessionGet_Output struct { 13 - Handle string `json:"handle"` 14 - Did string `json:"did"` 13 + Handle string `json:"handle" cborgen:"handle"` 14 + Did string `json:"did" cborgen:"did"` 15 15 } 16 16 17 17 func (t *SessionGet_Output) MarshalJSON() ([]byte, error) {
+4 -4
api/atproto/sessionrefresh.go
··· 10 10 // schema: com.atproto.session.refresh 11 11 12 12 type SessionRefresh_Output struct { 13 - AccessJwt string `json:"accessJwt"` 14 - RefreshJwt string `json:"refreshJwt"` 15 - Handle string `json:"handle"` 16 - Did string `json:"did"` 13 + Did string `json:"did" cborgen:"did"` 14 + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 15 + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 16 + Handle string `json:"handle" cborgen:"handle"` 17 17 } 18 18 19 19 func (t *SessionRefresh_Output) MarshalJSON() ([]byte, error) {
+1 -1
api/atproto/syncgetRoot.go
··· 10 10 // schema: com.atproto.sync.getRoot 11 11 12 12 type SyncGetRoot_Output struct { 13 - Root string `json:"root"` 13 + Root string `json:"root" cborgen:"root"` 14 14 } 15 15 16 16 func (t *SyncGetRoot_Output) MarshalJSON() ([]byte, error) {
+5 -5
api/bsky/actorcreateScene.go
··· 10 10 // schema: app.bsky.actor.createScene 11 11 12 12 type ActorCreateScene_Input struct { 13 - Handle string `json:"handle"` 14 - RecoveryKey string `json:"recoveryKey"` 13 + Handle string `json:"handle" cborgen:"handle"` 14 + RecoveryKey string `json:"recoveryKey" cborgen:"recoveryKey"` 15 15 } 16 16 17 17 func (t *ActorCreateScene_Input) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type ActorCreateScene_Output struct { 25 - Handle string `json:"handle"` 26 - Did string `json:"did"` 27 - Declaration *SystemDeclRef `json:"declaration"` 25 + Handle string `json:"handle" cborgen:"handle"` 26 + Did string `json:"did" cborgen:"did"` 27 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 28 28 } 29 29 30 30 func (t *ActorCreateScene_Output) MarshalJSON() ([]byte, error) {
+13 -13
api/bsky/actorgetProfile.go
··· 10 10 // schema: app.bsky.actor.getProfile 11 11 12 12 type ActorGetProfile_Output struct { 13 - Did string `json:"did"` 14 - Declaration *SystemDeclRef `json:"declaration"` 15 - Handle string `json:"handle"` 16 - DisplayName string `json:"displayName"` 17 - FollowersCount int64 `json:"followersCount"` 18 - MembersCount int64 `json:"membersCount"` 19 - PostsCount int64 `json:"postsCount"` 20 - Creator string `json:"creator"` 21 - Description string `json:"description"` 22 - FollowsCount int64 `json:"followsCount"` 23 - MyState *ActorGetProfile_MyState `json:"myState"` 13 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 14 + Creator string `json:"creator" cborgen:"creator"` 15 + DisplayName string `json:"displayName" cborgen:"displayName"` 16 + FollowersCount int64 `json:"followersCount" cborgen:"followersCount"` 17 + FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 18 + MembersCount int64 `json:"membersCount" cborgen:"membersCount"` 19 + PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 20 + MyState *ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 21 + Did string `json:"did" cborgen:"did"` 22 + Handle string `json:"handle" cborgen:"handle"` 23 + Description string `json:"description" cborgen:"description"` 24 24 } 25 25 26 26 func (t *ActorGetProfile_Output) MarshalJSON() ([]byte, error) { ··· 40 40 } 41 41 42 42 type ActorGetProfile_MyState struct { 43 - Follow string `json:"follow"` 44 - Member string `json:"member"` 43 + Follow string `json:"follow" cborgen:"follow"` 44 + Member string `json:"member" cborgen:"member"` 45 45 } 46 46 47 47 func (t *ActorGetProfile_MyState) MarshalJSON() ([]byte, error) {
+19 -19
api/bsky/actorgetSuggestions.go
··· 9 9 10 10 // schema: app.bsky.actor.getSuggestions 11 11 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) 20 + } 21 + 12 22 type ActorGetSuggestions_Output struct { 13 - Cursor string `json:"cursor"` 14 - Actors []*ActorGetSuggestions_Actor `json:"actors"` 23 + Cursor string `json:"cursor" cborgen:"cursor"` 24 + Actors []*ActorGetSuggestions_Actor `json:"actors" cborgen:"actors"` 15 25 } 16 26 17 27 func (t *ActorGetSuggestions_Output) MarshalJSON() ([]byte, error) { ··· 22 32 } 23 33 24 34 type ActorGetSuggestions_Actor struct { 25 - MyState *ActorGetSuggestions_MyState `json:"myState"` 26 - Did string `json:"did"` 27 - Declaration *SystemDeclRef `json:"declaration"` 28 - Handle string `json:"handle"` 29 - DisplayName string `json:"displayName"` 30 - Description string `json:"description"` 31 - IndexedAt string `json:"indexedAt"` 35 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 36 + 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"` 32 42 } 33 43 34 44 func (t *ActorGetSuggestions_Actor) MarshalJSON() ([]byte, error) { ··· 40 50 out["handle"] = t.Handle 41 51 out["indexedAt"] = t.IndexedAt 42 52 out["myState"] = t.MyState 43 - return json.Marshal(out) 44 - } 45 - 46 - type ActorGetSuggestions_MyState struct { 47 - Follow string `json:"follow"` 48 - } 49 - 50 - func (t *ActorGetSuggestions_MyState) MarshalJSON() ([]byte, error) { 51 - out := make(map[string]interface{}) 52 - out["follow"] = t.Follow 53 53 return json.Marshal(out) 54 54 } 55 55
+3 -2
api/bsky/actorprofile.go
··· 6 6 7 7 // schema: app.bsky.actor.profile 8 8 9 + // RECORDTYPE: ActorProfile 9 10 type ActorProfile struct { 10 - DisplayName string `json:"displayName"` 11 - Description string `json:"description"` 11 + DisplayName string `json:"displayName" cborgen:"displayName"` 12 + Description string `json:"description" cborgen:"description"` 12 13 } 13 14 14 15 func (t *ActorProfile) MarshalJSON() ([]byte, error) {
+6 -6
api/bsky/actorref.go
··· 7 7 // schema: app.bsky.actor.ref 8 8 9 9 type ActorRef struct { 10 - Did string `json:"did"` 11 - DeclarationCid string `json:"declarationCid"` 10 + Did string `json:"did" cborgen:"did"` 11 + DeclarationCid string `json:"declarationCid" cborgen:"declarationCid"` 12 12 } 13 13 14 14 func (t *ActorRef) MarshalJSON() ([]byte, error) { ··· 19 19 } 20 20 21 21 type ActorRef_WithInfo struct { 22 - Did string `json:"did"` 23 - Declaration *SystemDeclRef `json:"declaration"` 24 - Handle string `json:"handle"` 25 - DisplayName string `json:"displayName"` 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 26 } 27 27 28 28 func (t *ActorRef_WithInfo) MarshalJSON() ([]byte, error) {
+8 -8
api/bsky/actorsearch.go
··· 10 10 // schema: app.bsky.actor.search 11 11 12 12 type ActorSearch_Output struct { 13 - Cursor string `json:"cursor"` 14 - Users []*ActorSearch_User `json:"users"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Users []*ActorSearch_User `json:"users" cborgen:"users"` 15 15 } 16 16 17 17 func (t *ActorSearch_Output) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type ActorSearch_User struct { 25 - Did string `json:"did"` 26 - Declaration *SystemDeclRef `json:"declaration"` 27 - Handle string `json:"handle"` 28 - DisplayName string `json:"displayName"` 29 - Description string `json:"description"` 30 - IndexedAt string `json:"indexedAt"` 25 + Did string `json:"did" cborgen:"did"` 26 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 27 + 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 31 } 32 32 33 33 func (t *ActorSearch_User) MarshalJSON() ([]byte, error) {
+5 -5
api/bsky/actorsearchTypeahead.go
··· 10 10 // schema: app.bsky.actor.searchTypeahead 11 11 12 12 type ActorSearchTypeahead_Output struct { 13 - Users []*ActorSearchTypeahead_User `json:"users"` 13 + Users []*ActorSearchTypeahead_User `json:"users" cborgen:"users"` 14 14 } 15 15 16 16 func (t *ActorSearchTypeahead_Output) MarshalJSON() ([]byte, error) { ··· 20 20 } 21 21 22 22 type ActorSearchTypeahead_User struct { 23 - Did string `json:"did"` 24 - Declaration *SystemDeclRef `json:"declaration"` 25 - Handle string `json:"handle"` 26 - DisplayName string `json:"displayName"` 23 + Did string `json:"did" cborgen:"did"` 24 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 25 + Handle string `json:"handle" cborgen:"handle"` 26 + DisplayName string `json:"displayName" cborgen:"displayName"` 27 27 } 28 28 29 29 func (t *ActorSearchTypeahead_User) MarshalJSON() ([]byte, error) {
+6 -6
api/bsky/actorupdateProfile.go
··· 10 10 // schema: app.bsky.actor.updateProfile 11 11 12 12 type ActorUpdateProfile_Input struct { 13 - Did string `json:"did"` 14 - DisplayName string `json:"displayName"` 15 - Description string `json:"description"` 13 + Did string `json:"did" cborgen:"did"` 14 + DisplayName string `json:"displayName" cborgen:"displayName"` 15 + Description string `json:"description" cborgen:"description"` 16 16 } 17 17 18 18 func (t *ActorUpdateProfile_Input) MarshalJSON() ([]byte, error) { ··· 24 24 } 25 25 26 26 type ActorUpdateProfile_Output struct { 27 - Uri string `json:"uri"` 28 - Cid string `json:"cid"` 29 - Record any `json:"record"` 27 + Uri string `json:"uri" cborgen:"uri"` 28 + Cid string `json:"cid" cborgen:"cid"` 29 + Record any `json:"record" cborgen:"record"` 30 30 } 31 31 32 32 func (t *ActorUpdateProfile_Output) MarshalJSON() ([]byte, error) {
+1123
api/bsky/cbor_gen.go
··· 1 + // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 + 3 + package schemagen 4 + 5 + import ( 6 + "fmt" 7 + "io" 8 + "math" 9 + "sort" 10 + 11 + cid "github.com/ipfs/go-cid" 12 + cbg "github.com/whyrusleeping/cbor-gen" 13 + schemagen "github.com/whyrusleeping/gosky/api/atproto" 14 + xerrors "golang.org/x/xerrors" 15 + ) 16 + 17 + var _ = xerrors.Errorf 18 + var _ = cid.Undef 19 + var _ = math.E 20 + var _ = sort.Sort 21 + 22 + func (t *FeedPost) MarshalCBOR(w io.Writer) error { 23 + if t == nil { 24 + _, err := w.Write(cbg.CborNull) 25 + return err 26 + } 27 + 28 + cw := cbg.NewCborWriter(w) 29 + 30 + if _, err := cw.Write([]byte{164}); err != nil { 31 + return err 32 + } 33 + 34 + // t.Text (string) (string) 35 + if len("text") > cbg.MaxLength { 36 + return xerrors.Errorf("Value in field \"text\" was too long") 37 + } 38 + 39 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("text"))); err != nil { 40 + return err 41 + } 42 + if _, err := io.WriteString(w, string("text")); err != nil { 43 + return err 44 + } 45 + 46 + if len(t.Text) > cbg.MaxLength { 47 + return xerrors.Errorf("Value in field t.Text was too long") 48 + } 49 + 50 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Text))); err != nil { 51 + return err 52 + } 53 + if _, err := io.WriteString(w, string(t.Text)); err != nil { 54 + return err 55 + } 56 + 57 + // t.Entities ([]*schemagen.FeedPost_Entity) (slice) 58 + if len("entities") > cbg.MaxLength { 59 + return xerrors.Errorf("Value in field \"entities\" was too long") 60 + } 61 + 62 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("entities"))); err != nil { 63 + return err 64 + } 65 + if _, err := io.WriteString(w, string("entities")); err != nil { 66 + return err 67 + } 68 + 69 + if len(t.Entities) > cbg.MaxLength { 70 + return xerrors.Errorf("Slice value in field t.Entities was too long") 71 + } 72 + 73 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Entities))); err != nil { 74 + return err 75 + } 76 + for _, v := range t.Entities { 77 + if err := v.MarshalCBOR(cw); err != nil { 78 + return err 79 + } 80 + } 81 + 82 + // t.Reply (schemagen.FeedPost_ReplyRef) (struct) 83 + if len("reply") > cbg.MaxLength { 84 + return xerrors.Errorf("Value in field \"reply\" was too long") 85 + } 86 + 87 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("reply"))); err != nil { 88 + return err 89 + } 90 + if _, err := io.WriteString(w, string("reply")); err != nil { 91 + return err 92 + } 93 + 94 + if err := t.Reply.MarshalCBOR(cw); err != nil { 95 + return err 96 + } 97 + 98 + // t.CreatedAt (string) (string) 99 + if len("createdAt") > cbg.MaxLength { 100 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 101 + } 102 + 103 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 104 + return err 105 + } 106 + if _, err := io.WriteString(w, string("createdAt")); err != nil { 107 + return err 108 + } 109 + 110 + if len(t.CreatedAt) > cbg.MaxLength { 111 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 112 + } 113 + 114 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 115 + return err 116 + } 117 + if _, err := io.WriteString(w, string(t.CreatedAt)); err != nil { 118 + return err 119 + } 120 + return nil 121 + } 122 + 123 + func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { 124 + *t = FeedPost{} 125 + 126 + cr := cbg.NewCborReader(r) 127 + 128 + maj, extra, err := cr.ReadHeader() 129 + if err != nil { 130 + return err 131 + } 132 + defer func() { 133 + if err == io.EOF { 134 + err = io.ErrUnexpectedEOF 135 + } 136 + }() 137 + 138 + if maj != cbg.MajMap { 139 + return fmt.Errorf("cbor input should be of type map") 140 + } 141 + 142 + if extra > cbg.MaxLength { 143 + return fmt.Errorf("FeedPost: map struct too large (%d)", extra) 144 + } 145 + 146 + var name string 147 + n := extra 148 + 149 + for i := uint64(0); i < n; i++ { 150 + 151 + { 152 + sval, err := cbg.ReadString(cr) 153 + if err != nil { 154 + return err 155 + } 156 + 157 + name = string(sval) 158 + } 159 + 160 + switch name { 161 + // t.Text (string) (string) 162 + case "text": 163 + 164 + { 165 + sval, err := cbg.ReadString(cr) 166 + if err != nil { 167 + return err 168 + } 169 + 170 + t.Text = string(sval) 171 + } 172 + // t.Entities ([]*schemagen.FeedPost_Entity) (slice) 173 + case "entities": 174 + 175 + maj, extra, err = cr.ReadHeader() 176 + if err != nil { 177 + return err 178 + } 179 + 180 + if extra > cbg.MaxLength { 181 + return fmt.Errorf("t.Entities: array too large (%d)", extra) 182 + } 183 + 184 + if maj != cbg.MajArray { 185 + return fmt.Errorf("expected cbor array") 186 + } 187 + 188 + if extra > 0 { 189 + t.Entities = make([]*FeedPost_Entity, extra) 190 + } 191 + 192 + for i := 0; i < int(extra); i++ { 193 + 194 + var v FeedPost_Entity 195 + if err := v.UnmarshalCBOR(cr); err != nil { 196 + return err 197 + } 198 + 199 + t.Entities[i] = &v 200 + } 201 + 202 + // t.Reply (schemagen.FeedPost_ReplyRef) (struct) 203 + case "reply": 204 + 205 + { 206 + 207 + b, err := cr.ReadByte() 208 + if err != nil { 209 + return err 210 + } 211 + if b != cbg.CborNull[0] { 212 + if err := cr.UnreadByte(); err != nil { 213 + return err 214 + } 215 + t.Reply = new(FeedPost_ReplyRef) 216 + if err := t.Reply.UnmarshalCBOR(cr); err != nil { 217 + return xerrors.Errorf("unmarshaling t.Reply pointer: %w", err) 218 + } 219 + } 220 + 221 + } 222 + // t.CreatedAt (string) (string) 223 + case "createdAt": 224 + 225 + { 226 + sval, err := cbg.ReadString(cr) 227 + if err != nil { 228 + return err 229 + } 230 + 231 + t.CreatedAt = string(sval) 232 + } 233 + 234 + default: 235 + // Field doesn't exist on this type, so ignore it 236 + cbg.ScanForLinks(r, func(cid.Cid) {}) 237 + } 238 + } 239 + 240 + return nil 241 + } 242 + func (t *FeedRepost) MarshalCBOR(w io.Writer) error { 243 + if t == nil { 244 + _, err := w.Write(cbg.CborNull) 245 + return err 246 + } 247 + 248 + cw := cbg.NewCborWriter(w) 249 + 250 + if _, err := cw.Write([]byte{162}); err != nil { 251 + return err 252 + } 253 + 254 + // t.Subject (schemagen.RepoStrongRef) (struct) 255 + if len("subject") > cbg.MaxLength { 256 + return xerrors.Errorf("Value in field \"subject\" was too long") 257 + } 258 + 259 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 260 + return err 261 + } 262 + if _, err := io.WriteString(w, string("subject")); err != nil { 263 + return err 264 + } 265 + 266 + if err := t.Subject.MarshalCBOR(cw); err != nil { 267 + return err 268 + } 269 + 270 + // t.CreatedAt (string) (string) 271 + if len("createdAt") > cbg.MaxLength { 272 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 273 + } 274 + 275 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 276 + return err 277 + } 278 + if _, err := io.WriteString(w, string("createdAt")); err != nil { 279 + return err 280 + } 281 + 282 + if len(t.CreatedAt) > cbg.MaxLength { 283 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 284 + } 285 + 286 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 287 + return err 288 + } 289 + if _, err := io.WriteString(w, string(t.CreatedAt)); err != nil { 290 + return err 291 + } 292 + return nil 293 + } 294 + 295 + func (t *FeedRepost) UnmarshalCBOR(r io.Reader) (err error) { 296 + *t = FeedRepost{} 297 + 298 + cr := cbg.NewCborReader(r) 299 + 300 + maj, extra, err := cr.ReadHeader() 301 + if err != nil { 302 + return err 303 + } 304 + defer func() { 305 + if err == io.EOF { 306 + err = io.ErrUnexpectedEOF 307 + } 308 + }() 309 + 310 + if maj != cbg.MajMap { 311 + return fmt.Errorf("cbor input should be of type map") 312 + } 313 + 314 + if extra > cbg.MaxLength { 315 + return fmt.Errorf("FeedRepost: map struct too large (%d)", extra) 316 + } 317 + 318 + var name string 319 + n := extra 320 + 321 + for i := uint64(0); i < n; i++ { 322 + 323 + { 324 + sval, err := cbg.ReadString(cr) 325 + if err != nil { 326 + return err 327 + } 328 + 329 + name = string(sval) 330 + } 331 + 332 + switch name { 333 + // t.Subject (schemagen.RepoStrongRef) (struct) 334 + case "subject": 335 + 336 + { 337 + 338 + b, err := cr.ReadByte() 339 + if err != nil { 340 + return err 341 + } 342 + if b != cbg.CborNull[0] { 343 + if err := cr.UnreadByte(); err != nil { 344 + return err 345 + } 346 + t.Subject = new(schemagen.RepoStrongRef) 347 + if err := t.Subject.UnmarshalCBOR(cr); err != nil { 348 + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 349 + } 350 + } 351 + 352 + } 353 + // t.CreatedAt (string) (string) 354 + case "createdAt": 355 + 356 + { 357 + sval, err := cbg.ReadString(cr) 358 + if err != nil { 359 + return err 360 + } 361 + 362 + t.CreatedAt = string(sval) 363 + } 364 + 365 + default: 366 + // Field doesn't exist on this type, so ignore it 367 + cbg.ScanForLinks(r, func(cid.Cid) {}) 368 + } 369 + } 370 + 371 + return nil 372 + } 373 + func (t *FeedTrend) MarshalCBOR(w io.Writer) error { 374 + if t == nil { 375 + _, err := w.Write(cbg.CborNull) 376 + return err 377 + } 378 + 379 + cw := cbg.NewCborWriter(w) 380 + 381 + if _, err := cw.Write([]byte{162}); err != nil { 382 + return err 383 + } 384 + 385 + // t.Subject (schemagen.RepoStrongRef) (struct) 386 + if len("subject") > cbg.MaxLength { 387 + return xerrors.Errorf("Value in field \"subject\" was too long") 388 + } 389 + 390 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 391 + return err 392 + } 393 + if _, err := io.WriteString(w, string("subject")); err != nil { 394 + return err 395 + } 396 + 397 + if err := t.Subject.MarshalCBOR(cw); err != nil { 398 + return err 399 + } 400 + 401 + // t.CreatedAt (string) (string) 402 + if len("createdAt") > cbg.MaxLength { 403 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 404 + } 405 + 406 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 407 + return err 408 + } 409 + if _, err := io.WriteString(w, string("createdAt")); err != nil { 410 + return err 411 + } 412 + 413 + if len(t.CreatedAt) > cbg.MaxLength { 414 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 415 + } 416 + 417 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 418 + return err 419 + } 420 + if _, err := io.WriteString(w, string(t.CreatedAt)); err != nil { 421 + return err 422 + } 423 + return nil 424 + } 425 + 426 + func (t *FeedTrend) UnmarshalCBOR(r io.Reader) (err error) { 427 + *t = FeedTrend{} 428 + 429 + cr := cbg.NewCborReader(r) 430 + 431 + maj, extra, err := cr.ReadHeader() 432 + if err != nil { 433 + return err 434 + } 435 + defer func() { 436 + if err == io.EOF { 437 + err = io.ErrUnexpectedEOF 438 + } 439 + }() 440 + 441 + if maj != cbg.MajMap { 442 + return fmt.Errorf("cbor input should be of type map") 443 + } 444 + 445 + if extra > cbg.MaxLength { 446 + return fmt.Errorf("FeedTrend: map struct too large (%d)", extra) 447 + } 448 + 449 + var name string 450 + n := extra 451 + 452 + for i := uint64(0); i < n; i++ { 453 + 454 + { 455 + sval, err := cbg.ReadString(cr) 456 + if err != nil { 457 + return err 458 + } 459 + 460 + name = string(sval) 461 + } 462 + 463 + switch name { 464 + // t.Subject (schemagen.RepoStrongRef) (struct) 465 + case "subject": 466 + 467 + { 468 + 469 + b, err := cr.ReadByte() 470 + if err != nil { 471 + return err 472 + } 473 + if b != cbg.CborNull[0] { 474 + if err := cr.UnreadByte(); err != nil { 475 + return err 476 + } 477 + t.Subject = new(schemagen.RepoStrongRef) 478 + if err := t.Subject.UnmarshalCBOR(cr); err != nil { 479 + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 480 + } 481 + } 482 + 483 + } 484 + // t.CreatedAt (string) (string) 485 + case "createdAt": 486 + 487 + { 488 + sval, err := cbg.ReadString(cr) 489 + if err != nil { 490 + return err 491 + } 492 + 493 + t.CreatedAt = string(sval) 494 + } 495 + 496 + default: 497 + // Field doesn't exist on this type, so ignore it 498 + cbg.ScanForLinks(r, func(cid.Cid) {}) 499 + } 500 + } 501 + 502 + return nil 503 + } 504 + func (t *FeedVote) MarshalCBOR(w io.Writer) error { 505 + if t == nil { 506 + _, err := w.Write(cbg.CborNull) 507 + return err 508 + } 509 + 510 + cw := cbg.NewCborWriter(w) 511 + 512 + if _, err := cw.Write([]byte{163}); err != nil { 513 + return err 514 + } 515 + 516 + // t.Subject (schemagen.RepoStrongRef) (struct) 517 + if len("subject") > cbg.MaxLength { 518 + return xerrors.Errorf("Value in field \"subject\" was too long") 519 + } 520 + 521 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { 522 + return err 523 + } 524 + if _, err := io.WriteString(w, string("subject")); err != nil { 525 + return err 526 + } 527 + 528 + if err := t.Subject.MarshalCBOR(cw); err != nil { 529 + return err 530 + } 531 + 532 + // t.Direction (string) (string) 533 + if len("direction") > cbg.MaxLength { 534 + return xerrors.Errorf("Value in field \"direction\" was too long") 535 + } 536 + 537 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("direction"))); err != nil { 538 + return err 539 + } 540 + if _, err := io.WriteString(w, string("direction")); err != nil { 541 + return err 542 + } 543 + 544 + if len(t.Direction) > cbg.MaxLength { 545 + return xerrors.Errorf("Value in field t.Direction was too long") 546 + } 547 + 548 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Direction))); err != nil { 549 + return err 550 + } 551 + if _, err := io.WriteString(w, string(t.Direction)); err != nil { 552 + return err 553 + } 554 + 555 + // t.CreatedAt (string) (string) 556 + if len("createdAt") > cbg.MaxLength { 557 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 558 + } 559 + 560 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 561 + return err 562 + } 563 + if _, err := io.WriteString(w, string("createdAt")); err != nil { 564 + return err 565 + } 566 + 567 + if len(t.CreatedAt) > cbg.MaxLength { 568 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 569 + } 570 + 571 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 572 + return err 573 + } 574 + if _, err := io.WriteString(w, string(t.CreatedAt)); err != nil { 575 + return err 576 + } 577 + return nil 578 + } 579 + 580 + func (t *FeedVote) UnmarshalCBOR(r io.Reader) (err error) { 581 + *t = FeedVote{} 582 + 583 + cr := cbg.NewCborReader(r) 584 + 585 + maj, extra, err := cr.ReadHeader() 586 + if err != nil { 587 + return err 588 + } 589 + defer func() { 590 + if err == io.EOF { 591 + err = io.ErrUnexpectedEOF 592 + } 593 + }() 594 + 595 + if maj != cbg.MajMap { 596 + return fmt.Errorf("cbor input should be of type map") 597 + } 598 + 599 + if extra > cbg.MaxLength { 600 + return fmt.Errorf("FeedVote: map struct too large (%d)", extra) 601 + } 602 + 603 + var name string 604 + n := extra 605 + 606 + for i := uint64(0); i < n; i++ { 607 + 608 + { 609 + sval, err := cbg.ReadString(cr) 610 + if err != nil { 611 + return err 612 + } 613 + 614 + name = string(sval) 615 + } 616 + 617 + switch name { 618 + // t.Subject (schemagen.RepoStrongRef) (struct) 619 + case "subject": 620 + 621 + { 622 + 623 + b, err := cr.ReadByte() 624 + if err != nil { 625 + return err 626 + } 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 + 637 + } 638 + // t.Direction (string) (string) 639 + case "direction": 640 + 641 + { 642 + sval, err := cbg.ReadString(cr) 643 + if err != nil { 644 + return err 645 + } 646 + 647 + t.Direction = string(sval) 648 + } 649 + // t.CreatedAt (string) (string) 650 + case "createdAt": 651 + 652 + { 653 + sval, err := cbg.ReadString(cr) 654 + if err != nil { 655 + return err 656 + } 657 + 658 + t.CreatedAt = string(sval) 659 + } 660 + 661 + default: 662 + // Field doesn't exist on this type, so ignore it 663 + cbg.ScanForLinks(r, func(cid.Cid) {}) 664 + } 665 + } 666 + 667 + return nil 668 + } 669 + func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { 670 + if t == nil { 671 + _, err := w.Write(cbg.CborNull) 672 + return err 673 + } 674 + 675 + cw := cbg.NewCborWriter(w) 676 + 677 + if _, err := cw.Write([]byte{163}); err != nil { 678 + return err 679 + } 680 + 681 + // t.Index (schemagen.FeedPost_TextSlice) (struct) 682 + if len("index") > cbg.MaxLength { 683 + return xerrors.Errorf("Value in field \"index\" was too long") 684 + } 685 + 686 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("index"))); err != nil { 687 + return err 688 + } 689 + if _, err := io.WriteString(w, string("index")); err != nil { 690 + return err 691 + } 692 + 693 + if err := t.Index.MarshalCBOR(cw); err != nil { 694 + return err 695 + } 696 + 697 + // t.Type (string) (string) 698 + if len("type") > cbg.MaxLength { 699 + return xerrors.Errorf("Value in field \"type\" was too long") 700 + } 701 + 702 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("type"))); err != nil { 703 + return err 704 + } 705 + if _, err := io.WriteString(w, string("type")); err != nil { 706 + return err 707 + } 708 + 709 + if len(t.Type) > cbg.MaxLength { 710 + return xerrors.Errorf("Value in field t.Type was too long") 711 + } 712 + 713 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil { 714 + return err 715 + } 716 + if _, err := io.WriteString(w, string(t.Type)); err != nil { 717 + return err 718 + } 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 + return nil 743 + } 744 + 745 + func (t *FeedPost_Entity) UnmarshalCBOR(r io.Reader) (err error) { 746 + *t = FeedPost_Entity{} 747 + 748 + cr := cbg.NewCborReader(r) 749 + 750 + maj, extra, err := cr.ReadHeader() 751 + if err != nil { 752 + return err 753 + } 754 + defer func() { 755 + if err == io.EOF { 756 + err = io.ErrUnexpectedEOF 757 + } 758 + }() 759 + 760 + if maj != cbg.MajMap { 761 + return fmt.Errorf("cbor input should be of type map") 762 + } 763 + 764 + if extra > cbg.MaxLength { 765 + return fmt.Errorf("FeedPost_Entity: map struct too large (%d)", extra) 766 + } 767 + 768 + var name string 769 + n := extra 770 + 771 + for i := uint64(0); i < n; i++ { 772 + 773 + { 774 + sval, err := cbg.ReadString(cr) 775 + if err != nil { 776 + return err 777 + } 778 + 779 + name = string(sval) 780 + } 781 + 782 + switch name { 783 + // t.Index (schemagen.FeedPost_TextSlice) (struct) 784 + case "index": 785 + 786 + { 787 + 788 + b, err := cr.ReadByte() 789 + if err != nil { 790 + return err 791 + } 792 + if b != cbg.CborNull[0] { 793 + if err := cr.UnreadByte(); err != nil { 794 + return err 795 + } 796 + t.Index = new(FeedPost_TextSlice) 797 + if err := t.Index.UnmarshalCBOR(cr); err != nil { 798 + return xerrors.Errorf("unmarshaling t.Index pointer: %w", err) 799 + } 800 + } 801 + 802 + } 803 + // t.Type (string) (string) 804 + case "type": 805 + 806 + { 807 + sval, err := cbg.ReadString(cr) 808 + if err != nil { 809 + return err 810 + } 811 + 812 + t.Type = string(sval) 813 + } 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 + 826 + default: 827 + // Field doesn't exist on this type, so ignore it 828 + cbg.ScanForLinks(r, func(cid.Cid) {}) 829 + } 830 + } 831 + 832 + return nil 833 + } 834 + func (t *FeedPost_ReplyRef) MarshalCBOR(w io.Writer) error { 835 + if t == nil { 836 + _, err := w.Write(cbg.CborNull) 837 + return err 838 + } 839 + 840 + cw := cbg.NewCborWriter(w) 841 + 842 + if _, err := cw.Write([]byte{162}); err != nil { 843 + return err 844 + } 845 + 846 + // t.Parent (schemagen.RepoStrongRef) (struct) 847 + if len("parent") > cbg.MaxLength { 848 + return xerrors.Errorf("Value in field \"parent\" was too long") 849 + } 850 + 851 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("parent"))); err != nil { 852 + return err 853 + } 854 + if _, err := io.WriteString(w, string("parent")); err != nil { 855 + return err 856 + } 857 + 858 + if err := t.Parent.MarshalCBOR(cw); err != nil { 859 + return err 860 + } 861 + 862 + // t.Root (schemagen.RepoStrongRef) (struct) 863 + if len("root") > cbg.MaxLength { 864 + return xerrors.Errorf("Value in field \"root\" was too long") 865 + } 866 + 867 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("root"))); err != nil { 868 + return err 869 + } 870 + if _, err := io.WriteString(w, string("root")); err != nil { 871 + return err 872 + } 873 + 874 + if err := t.Root.MarshalCBOR(cw); err != nil { 875 + return err 876 + } 877 + return nil 878 + } 879 + 880 + func (t *FeedPost_ReplyRef) UnmarshalCBOR(r io.Reader) (err error) { 881 + *t = FeedPost_ReplyRef{} 882 + 883 + cr := cbg.NewCborReader(r) 884 + 885 + maj, extra, err := cr.ReadHeader() 886 + if err != nil { 887 + return err 888 + } 889 + defer func() { 890 + if err == io.EOF { 891 + err = io.ErrUnexpectedEOF 892 + } 893 + }() 894 + 895 + if maj != cbg.MajMap { 896 + return fmt.Errorf("cbor input should be of type map") 897 + } 898 + 899 + if extra > cbg.MaxLength { 900 + return fmt.Errorf("FeedPost_ReplyRef: map struct too large (%d)", extra) 901 + } 902 + 903 + var name string 904 + n := extra 905 + 906 + for i := uint64(0); i < n; i++ { 907 + 908 + { 909 + sval, err := cbg.ReadString(cr) 910 + if err != nil { 911 + return err 912 + } 913 + 914 + name = string(sval) 915 + } 916 + 917 + switch name { 918 + // t.Parent (schemagen.RepoStrongRef) (struct) 919 + case "parent": 920 + 921 + { 922 + 923 + b, err := cr.ReadByte() 924 + if err != nil { 925 + return err 926 + } 927 + if b != cbg.CborNull[0] { 928 + if err := cr.UnreadByte(); err != nil { 929 + return err 930 + } 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) 934 + } 935 + } 936 + 937 + } 938 + // t.Root (schemagen.RepoStrongRef) (struct) 939 + case "root": 940 + 941 + { 942 + 943 + b, err := cr.ReadByte() 944 + if err != nil { 945 + return err 946 + } 947 + if b != cbg.CborNull[0] { 948 + if err := cr.UnreadByte(); err != nil { 949 + return err 950 + } 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) 954 + } 955 + } 956 + 957 + } 958 + 959 + default: 960 + // Field doesn't exist on this type, so ignore it 961 + cbg.ScanForLinks(r, func(cid.Cid) {}) 962 + } 963 + } 964 + 965 + return nil 966 + } 967 + func (t *FeedPost_TextSlice) MarshalCBOR(w io.Writer) error { 968 + if t == nil { 969 + _, err := w.Write(cbg.CborNull) 970 + return err 971 + } 972 + 973 + cw := cbg.NewCborWriter(w) 974 + 975 + if _, err := cw.Write([]byte{162}); err != nil { 976 + return err 977 + } 978 + 979 + // t.Start (int64) (int64) 980 + if len("start") > cbg.MaxLength { 981 + return xerrors.Errorf("Value in field \"start\" was too long") 982 + } 983 + 984 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("start"))); err != nil { 985 + return err 986 + } 987 + if _, err := io.WriteString(w, string("start")); err != nil { 988 + return err 989 + } 990 + 991 + if t.Start >= 0 { 992 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Start)); err != nil { 993 + return err 994 + } 995 + } else { 996 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Start-1)); err != nil { 997 + return err 998 + } 999 + } 1000 + 1001 + // t.End (int64) (int64) 1002 + if len("end") > cbg.MaxLength { 1003 + return xerrors.Errorf("Value in field \"end\" was too long") 1004 + } 1005 + 1006 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("end"))); err != nil { 1007 + return err 1008 + } 1009 + if _, err := io.WriteString(w, string("end")); err != nil { 1010 + return err 1011 + } 1012 + 1013 + if t.End >= 0 { 1014 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.End)); err != nil { 1015 + return err 1016 + } 1017 + } else { 1018 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.End-1)); err != nil { 1019 + return err 1020 + } 1021 + } 1022 + return nil 1023 + } 1024 + 1025 + func (t *FeedPost_TextSlice) UnmarshalCBOR(r io.Reader) (err error) { 1026 + *t = FeedPost_TextSlice{} 1027 + 1028 + cr := cbg.NewCborReader(r) 1029 + 1030 + maj, extra, err := cr.ReadHeader() 1031 + if err != nil { 1032 + return err 1033 + } 1034 + defer func() { 1035 + if err == io.EOF { 1036 + err = io.ErrUnexpectedEOF 1037 + } 1038 + }() 1039 + 1040 + if maj != cbg.MajMap { 1041 + return fmt.Errorf("cbor input should be of type map") 1042 + } 1043 + 1044 + if extra > cbg.MaxLength { 1045 + return fmt.Errorf("FeedPost_TextSlice: map struct too large (%d)", extra) 1046 + } 1047 + 1048 + var name string 1049 + n := extra 1050 + 1051 + for i := uint64(0); i < n; i++ { 1052 + 1053 + { 1054 + sval, err := cbg.ReadString(cr) 1055 + if err != nil { 1056 + return err 1057 + } 1058 + 1059 + name = string(sval) 1060 + } 1061 + 1062 + switch name { 1063 + // t.Start (int64) (int64) 1064 + case "start": 1065 + { 1066 + maj, extra, err := cr.ReadHeader() 1067 + var extraI int64 1068 + if err != nil { 1069 + return err 1070 + } 1071 + switch maj { 1072 + case cbg.MajUnsignedInt: 1073 + extraI = int64(extra) 1074 + if extraI < 0 { 1075 + return fmt.Errorf("int64 positive overflow") 1076 + } 1077 + case cbg.MajNegativeInt: 1078 + extraI = int64(extra) 1079 + if extraI < 0 { 1080 + return fmt.Errorf("int64 negative oveflow") 1081 + } 1082 + extraI = -1 - extraI 1083 + default: 1084 + return fmt.Errorf("wrong type for int64 field: %d", maj) 1085 + } 1086 + 1087 + t.Start = int64(extraI) 1088 + } 1089 + // t.End (int64) (int64) 1090 + case "end": 1091 + { 1092 + maj, extra, err := cr.ReadHeader() 1093 + var extraI int64 1094 + if err != nil { 1095 + return err 1096 + } 1097 + switch maj { 1098 + case cbg.MajUnsignedInt: 1099 + extraI = int64(extra) 1100 + if extraI < 0 { 1101 + return fmt.Errorf("int64 positive overflow") 1102 + } 1103 + case cbg.MajNegativeInt: 1104 + extraI = int64(extra) 1105 + if extraI < 0 { 1106 + return fmt.Errorf("int64 negative oveflow") 1107 + } 1108 + extraI = -1 - extraI 1109 + default: 1110 + return fmt.Errorf("wrong type for int64 field: %d", maj) 1111 + } 1112 + 1113 + t.End = int64(extraI) 1114 + } 1115 + 1116 + default: 1117 + // Field doesn't exist on this type, so ignore it 1118 + cbg.ScanForLinks(r, func(cid.Cid) {}) 1119 + } 1120 + } 1121 + 1122 + return nil 1123 + }
+26 -26
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) 29 + } 30 + 12 31 type FeedEmbed struct { 13 - Items []*FeedEmbed_Items_Elem `json:"items"` 32 + Items []*FeedEmbed_Items_Elem `json:"items" cborgen:"items"` 14 33 } 15 34 16 35 func (t *FeedEmbed) MarshalJSON() ([]byte, error) { ··· 60 79 } 61 80 62 81 type FeedEmbed_Media struct { 63 - Alt string `json:"alt"` 64 - Thumb *util.Blob `json:"thumb"` 65 - Original *util.Blob `json:"original"` 82 + Alt string `json:"alt" cborgen:"alt"` 83 + Thumb *util.Blob `json:"thumb" cborgen:"thumb"` 84 + Original *util.Blob `json:"original" cborgen:"original"` 66 85 } 67 86 68 87 func (t *FeedEmbed_Media) MarshalJSON() ([]byte, error) { ··· 74 93 } 75 94 76 95 type FeedEmbed_Record struct { 77 - Type string `json:"type"` 78 - Author *ActorRef_WithInfo `json:"author"` 79 - Record any `json:"record"` 96 + Type string `json:"type" cborgen:"type"` 97 + Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 98 + Record any `json:"record" cborgen:"record"` 80 99 } 81 100 82 101 func (t *FeedEmbed_Record) MarshalJSON() ([]byte, error) { ··· 87 106 out["type"] = t.Type 88 107 return json.Marshal(out) 89 108 } 90 - 91 - type FeedEmbed_External struct { 92 - Type string `json:"type"` 93 - Uri string `json:"uri"` 94 - Title string `json:"title"` 95 - Description string `json:"description"` 96 - ImageUri string `json:"imageUri"` 97 - } 98 - 99 - func (t *FeedEmbed_External) MarshalJSON() ([]byte, error) { 100 - t.Type = "external" 101 - out := make(map[string]interface{}) 102 - out["description"] = t.Description 103 - out["imageUri"] = t.ImageUri 104 - out["title"] = t.Title 105 - out["type"] = t.Type 106 - out["uri"] = t.Uri 107 - return json.Marshal(out) 108 - }
+18 -18
api/bsky/feedgetAuthorFeed.go
··· 10 10 // schema: app.bsky.feed.getAuthorFeed 11 11 12 12 type FeedGetAuthorFeed_Output struct { 13 - Cursor string `json:"cursor"` 14 - Feed []*FeedGetAuthorFeed_FeedItem `json:"feed"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Feed []*FeedGetAuthorFeed_FeedItem `json:"feed" cborgen:"feed"` 15 15 } 16 16 17 17 func (t *FeedGetAuthorFeed_Output) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type FeedGetAuthorFeed_FeedItem struct { 25 - IndexedAt string `json:"indexedAt"` 26 - Cid string `json:"cid"` 27 - TrendedBy *ActorRef_WithInfo `json:"trendedBy"` 28 - Record any `json:"record"` 29 - ReplyCount int64 `json:"replyCount"` 30 - RepostCount int64 `json:"repostCount"` 31 - UpvoteCount int64 `json:"upvoteCount"` 32 - DownvoteCount int64 `json:"downvoteCount"` 33 - MyState *FeedGetAuthorFeed_MyState `json:"myState"` 34 - Uri string `json:"uri"` 35 - Author *ActorRef_WithInfo `json:"author"` 36 - RepostedBy *ActorRef_WithInfo `json:"repostedBy"` 37 - Embed *FeedEmbed `json:"embed"` 25 + Uri string `json:"uri" cborgen:"uri"` 26 + RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 27 + Record any `json:"record" cborgen:"record"` 28 + ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 29 + RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 30 + UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 31 + DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 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 38 } 39 39 40 40 func (t *FeedGetAuthorFeed_FeedItem) MarshalJSON() ([]byte, error) { ··· 56 56 } 57 57 58 58 type FeedGetAuthorFeed_MyState struct { 59 - Downvote string `json:"downvote"` 60 - Repost string `json:"repost"` 61 - Upvote string `json:"upvote"` 59 + Upvote string `json:"upvote" cborgen:"upvote"` 60 + Downvote string `json:"downvote" cborgen:"downvote"` 61 + Repost string `json:"repost" cborgen:"repost"` 62 62 } 63 63 64 64 func (t *FeedGetAuthorFeed_MyState) MarshalJSON() ([]byte, error) {
+47 -47
api/bsky/feedgetPostThread.go
··· 11 11 12 12 // schema: app.bsky.feed.getPostThread 13 13 14 - type FeedGetPostThread_NotFoundPost struct { 15 - Uri string `json:"uri"` 16 - NotFound bool `json:"notFound"` 17 - } 18 - 19 - func (t *FeedGetPostThread_NotFoundPost) MarshalJSON() ([]byte, error) { 20 - t.NotFound = true 21 - out := make(map[string]interface{}) 22 - out["notFound"] = t.NotFound 23 - out["uri"] = t.Uri 24 - return json.Marshal(out) 25 - } 26 - 27 - type FeedGetPostThread_MyState struct { 28 - Repost string `json:"repost"` 29 - Upvote string `json:"upvote"` 30 - Downvote string `json:"downvote"` 31 - } 32 - 33 - func (t *FeedGetPostThread_MyState) MarshalJSON() ([]byte, error) { 34 - out := make(map[string]interface{}) 35 - out["downvote"] = t.Downvote 36 - out["repost"] = t.Repost 37 - out["upvote"] = t.Upvote 38 - return json.Marshal(out) 39 - } 40 - 41 14 type FeedGetPostThread_Output struct { 42 - Thread *FeedGetPostThread_Output_Thread `json:"thread"` 15 + Thread *FeedGetPostThread_Output_Thread `json:"thread" cborgen:"thread"` 43 16 } 44 17 45 18 func (t *FeedGetPostThread_Output) MarshalJSON() ([]byte, error) { ··· 82 55 } 83 56 84 57 type FeedGetPostThread_Post struct { 85 - ReplyCount int64 `json:"replyCount"` 86 - MyState *FeedGetPostThread_MyState `json:"myState"` 87 - Uri string `json:"uri"` 88 - Parent *FeedGetPostThread_Post_Parent `json:"parent"` 89 - Record any `json:"record"` 90 - Embed *FeedEmbed `json:"embed"` 91 - Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies"` 92 - RepostCount int64 `json:"repostCount"` 93 - UpvoteCount int64 `json:"upvoteCount"` 94 - DownvoteCount int64 `json:"downvoteCount"` 95 - Cid string `json:"cid"` 96 - Author *ActorRef_WithInfo `json:"author"` 97 - IndexedAt string `json:"indexedAt"` 58 + Uri string `json:"uri" cborgen:"uri"` 59 + Embed *FeedEmbed `json:"embed" cborgen:"embed"` 60 + RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 61 + Parent *FeedGetPostThread_Post_Parent `json:"parent" cborgen:"parent"` 62 + ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 63 + Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies" cborgen:"replies"` 64 + 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 + MyState *FeedGetPostThread_MyState `json:"myState" cborgen:"myState"` 98 71 } 99 72 100 73 func (t *FeedGetPostThread_Post) MarshalJSON() ([]byte, error) { ··· 115 88 return json.Marshal(out) 116 89 } 117 90 118 - type FeedGetPostThread_Post_Parent struct { 91 + type FeedGetPostThread_Post_Replies_Elem struct { 119 92 FeedGetPostThread_Post *FeedGetPostThread_Post 120 93 FeedGetPostThread_NotFoundPost *FeedGetPostThread_NotFoundPost 121 94 } 122 95 123 - func (t *FeedGetPostThread_Post_Parent) MarshalJSON() ([]byte, error) { 96 + func (t *FeedGetPostThread_Post_Replies_Elem) MarshalJSON() ([]byte, error) { 124 97 if t.FeedGetPostThread_Post != nil { 125 98 return json.Marshal(t.FeedGetPostThread_Post) 126 99 } ··· 129 102 } 130 103 return nil, fmt.Errorf("cannot marshal empty enum") 131 104 } 132 - func (t *FeedGetPostThread_Post_Parent) UnmarshalJSON(b []byte) error { 105 + func (t *FeedGetPostThread_Post_Replies_Elem) UnmarshalJSON(b []byte) error { 133 106 typ, err := util.EnumTypeExtract(b) 134 107 if err != nil { 135 108 return err ··· 148 121 } 149 122 } 150 123 151 - type FeedGetPostThread_Post_Replies_Elem struct { 124 + type FeedGetPostThread_Post_Parent struct { 152 125 FeedGetPostThread_Post *FeedGetPostThread_Post 153 126 FeedGetPostThread_NotFoundPost *FeedGetPostThread_NotFoundPost 154 127 } 155 128 156 - func (t *FeedGetPostThread_Post_Replies_Elem) MarshalJSON() ([]byte, error) { 129 + func (t *FeedGetPostThread_Post_Parent) MarshalJSON() ([]byte, error) { 157 130 if t.FeedGetPostThread_Post != nil { 158 131 return json.Marshal(t.FeedGetPostThread_Post) 159 132 } ··· 162 135 } 163 136 return nil, fmt.Errorf("cannot marshal empty enum") 164 137 } 165 - func (t *FeedGetPostThread_Post_Replies_Elem) UnmarshalJSON(b []byte) error { 138 + func (t *FeedGetPostThread_Post_Parent) UnmarshalJSON(b []byte) error { 166 139 typ, err := util.EnumTypeExtract(b) 167 140 if err != nil { 168 141 return err ··· 179 152 default: 180 153 return nil 181 154 } 155 + } 156 + 157 + type FeedGetPostThread_NotFoundPost struct { 158 + Uri string `json:"uri" cborgen:"uri"` 159 + NotFound bool `json:"notFound" cborgen:"notFound"` 160 + } 161 + 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 + type FeedGetPostThread_MyState struct { 171 + Repost string `json:"repost" cborgen:"repost"` 172 + Upvote string `json:"upvote" cborgen:"upvote"` 173 + 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 182 } 183 183 184 184 func FeedGetPostThread(ctx context.Context, c *xrpc.Client, depth int64, uri string) (*FeedGetPostThread_Output, error) {
+10 -10
api/bsky/feedgetRepostedBy.go
··· 10 10 // schema: app.bsky.feed.getRepostedBy 11 11 12 12 type FeedGetRepostedBy_Output struct { 13 - Uri string `json:"uri"` 14 - Cid string `json:"cid"` 15 - Cursor string `json:"cursor"` 16 - RepostedBy []*FeedGetRepostedBy_RepostedBy `json:"repostedBy"` 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"` 17 17 } 18 18 19 19 func (t *FeedGetRepostedBy_Output) MarshalJSON() ([]byte, error) { ··· 26 26 } 27 27 28 28 type FeedGetRepostedBy_RepostedBy struct { 29 - Did string `json:"did"` 30 - Declaration *SystemDeclRef `json:"declaration"` 31 - Handle string `json:"handle"` 32 - DisplayName string `json:"displayName"` 33 - CreatedAt string `json:"createdAt"` 34 - IndexedAt string `json:"indexedAt"` 29 + DisplayName string `json:"displayName" cborgen:"displayName"` 30 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 31 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 32 + Did string `json:"did" cborgen:"did"` 33 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 34 + Handle string `json:"handle" cborgen:"handle"` 35 35 } 36 36 37 37 func (t *FeedGetRepostedBy_RepostedBy) MarshalJSON() ([]byte, error) {
+18 -18
api/bsky/feedgetTimeline.go
··· 10 10 // schema: app.bsky.feed.getTimeline 11 11 12 12 type FeedGetTimeline_Output struct { 13 - Cursor string `json:"cursor"` 14 - Feed []*FeedGetTimeline_FeedItem `json:"feed"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Feed []*FeedGetTimeline_FeedItem `json:"feed" cborgen:"feed"` 15 15 } 16 16 17 17 func (t *FeedGetTimeline_Output) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type FeedGetTimeline_FeedItem struct { 25 - Embed *FeedEmbed `json:"embed"` 26 - ReplyCount int64 `json:"replyCount"` 27 - DownvoteCount int64 `json:"downvoteCount"` 28 - Author *ActorRef_WithInfo `json:"author"` 29 - TrendedBy *ActorRef_WithInfo `json:"trendedBy"` 30 - RepostedBy *ActorRef_WithInfo `json:"repostedBy"` 31 - RepostCount int64 `json:"repostCount"` 32 - UpvoteCount int64 `json:"upvoteCount"` 33 - IndexedAt string `json:"indexedAt"` 34 - MyState *FeedGetTimeline_MyState `json:"myState"` 35 - Uri string `json:"uri"` 36 - Cid string `json:"cid"` 37 - Record any `json:"record"` 25 + Cid string `json:"cid" cborgen:"cid"` 26 + RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 27 + Embed *FeedEmbed `json:"embed" cborgen:"embed"` 28 + RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 29 + DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 30 + MyState *FeedGetTimeline_MyState `json:"myState" cborgen:"myState"` 31 + Uri string `json:"uri" cborgen:"uri"` 32 + 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 38 } 39 39 40 40 func (t *FeedGetTimeline_FeedItem) MarshalJSON() ([]byte, error) { ··· 56 56 } 57 57 58 58 type FeedGetTimeline_MyState struct { 59 - Repost string `json:"repost"` 60 - Upvote string `json:"upvote"` 61 - Downvote string `json:"downvote"` 59 + Repost string `json:"repost" cborgen:"repost"` 60 + Upvote string `json:"upvote" cborgen:"upvote"` 61 + Downvote string `json:"downvote" cborgen:"downvote"` 62 62 } 63 63 64 64 func (t *FeedGetTimeline_MyState) MarshalJSON() ([]byte, error) {
+8 -8
api/bsky/feedgetVotes.go
··· 10 10 // schema: app.bsky.feed.getVotes 11 11 12 12 type FeedGetVotes_Output struct { 13 - Uri string `json:"uri"` 14 - Cid string `json:"cid"` 15 - Cursor string `json:"cursor"` 16 - Votes []*FeedGetVotes_Vote `json:"votes"` 13 + Uri string `json:"uri" cborgen:"uri"` 14 + Cid string `json:"cid" cborgen:"cid"` 15 + Cursor string `json:"cursor" cborgen:"cursor"` 16 + Votes []*FeedGetVotes_Vote `json:"votes" cborgen:"votes"` 17 17 } 18 18 19 19 func (t *FeedGetVotes_Output) MarshalJSON() ([]byte, error) { ··· 26 26 } 27 27 28 28 type FeedGetVotes_Vote struct { 29 - CreatedAt string `json:"createdAt"` 30 - Actor *ActorRef_WithInfo `json:"actor"` 31 - Direction string `json:"direction"` 32 - IndexedAt string `json:"indexedAt"` 29 + Direction string `json:"direction" cborgen:"direction"` 30 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 31 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 32 + Actor *ActorRef_WithInfo `json:"actor" cborgen:"actor"` 33 33 } 34 34 35 35 func (t *FeedGetVotes_Vote) MarshalJSON() ([]byte, error) {
+31 -30
api/bsky/feedpost.go
··· 8 8 9 9 // schema: app.bsky.feed.post 10 10 11 - type FeedPost struct { 12 - Entities []*FeedPost_Entity `json:"entities"` 13 - Reply *FeedPost_ReplyRef `json:"reply"` 14 - CreatedAt string `json:"createdAt"` 15 - Text string `json:"text"` 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"` 16 15 } 17 16 18 - func (t *FeedPost) MarshalJSON() ([]byte, error) { 17 + func (t *FeedPost_Entity) MarshalJSON() ([]byte, error) { 19 18 out := make(map[string]interface{}) 20 - out["createdAt"] = t.CreatedAt 21 - out["entities"] = t.Entities 22 - out["reply"] = t.Reply 23 - out["text"] = t.Text 19 + out["index"] = t.Index 20 + out["type"] = t.Type 21 + out["value"] = t.Value 24 22 return json.Marshal(out) 25 23 } 26 24 27 - type FeedPost_ReplyRef struct { 28 - Root *comatprototypes.RepoStrongRef `json:"root"` 29 - Parent *comatprototypes.RepoStrongRef `json:"parent"` 25 + type FeedPost_TextSlice struct { 26 + Start int64 `json:"start" cborgen:"start"` 27 + End int64 `json:"end" cborgen:"end"` 30 28 } 31 29 32 - func (t *FeedPost_ReplyRef) MarshalJSON() ([]byte, error) { 30 + func (t *FeedPost_TextSlice) MarshalJSON() ([]byte, error) { 33 31 out := make(map[string]interface{}) 34 - out["parent"] = t.Parent 35 - out["root"] = t.Root 32 + out["end"] = t.End 33 + out["start"] = t.Start 36 34 return json.Marshal(out) 37 35 } 38 36 39 - type FeedPost_Entity struct { 40 - Index *FeedPost_TextSlice `json:"index"` 41 - Type string `json:"type"` 42 - Value string `json:"value"` 37 + // RECORDTYPE: FeedPost 38 + 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"` 43 43 } 44 44 45 - func (t *FeedPost_Entity) MarshalJSON() ([]byte, error) { 45 + func (t *FeedPost) MarshalJSON() ([]byte, error) { 46 46 out := make(map[string]interface{}) 47 - out["index"] = t.Index 48 - out["type"] = t.Type 49 - out["value"] = t.Value 47 + out["createdAt"] = t.CreatedAt 48 + out["entities"] = t.Entities 49 + out["reply"] = t.Reply 50 + out["text"] = t.Text 50 51 return json.Marshal(out) 51 52 } 52 53 53 - type FeedPost_TextSlice struct { 54 - End int64 `json:"end"` 55 - Start int64 `json:"start"` 54 + type FeedPost_ReplyRef struct { 55 + Parent *comatprototypes.RepoStrongRef `json:"parent" cborgen:"parent"` 56 + Root *comatprototypes.RepoStrongRef `json:"root" cborgen:"root"` 56 57 } 57 58 58 - func (t *FeedPost_TextSlice) MarshalJSON() ([]byte, error) { 59 + func (t *FeedPost_ReplyRef) MarshalJSON() ([]byte, error) { 59 60 out := make(map[string]interface{}) 60 - out["end"] = t.End 61 - out["start"] = t.Start 61 + out["parent"] = t.Parent 62 + out["root"] = t.Root 62 63 return json.Marshal(out) 63 64 }
+3 -2
api/bsky/feedrepost.go
··· 8 8 9 9 // schema: app.bsky.feed.repost 10 10 11 + // RECORDTYPE: FeedRepost 11 12 type FeedRepost struct { 12 - Subject *comatprototypes.RepoStrongRef `json:"subject"` 13 - CreatedAt string `json:"createdAt"` 13 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 14 15 } 15 16 16 17 func (t *FeedRepost) MarshalJSON() ([]byte, error) {
+4 -4
api/bsky/feedsetVote.go
··· 11 11 // schema: app.bsky.feed.setVote 12 12 13 13 type FeedSetVote_Input struct { 14 - Subject *comatprototypes.RepoStrongRef `json:"subject"` 15 - Direction string `json:"direction"` 14 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 15 + Direction string `json:"direction" cborgen:"direction"` 16 16 } 17 17 18 18 func (t *FeedSetVote_Input) MarshalJSON() ([]byte, error) { ··· 23 23 } 24 24 25 25 type FeedSetVote_Output struct { 26 - Downvote string `json:"downvote"` 27 - Upvote string `json:"upvote"` 26 + Upvote string `json:"upvote" cborgen:"upvote"` 27 + Downvote string `json:"downvote" cborgen:"downvote"` 28 28 } 29 29 30 30 func (t *FeedSetVote_Output) MarshalJSON() ([]byte, error) {
+3 -2
api/bsky/feedtrend.go
··· 8 8 9 9 // schema: app.bsky.feed.trend 10 10 11 + // RECORDTYPE: FeedTrend 11 12 type FeedTrend struct { 12 - Subject *comatprototypes.RepoStrongRef `json:"subject"` 13 - CreatedAt string `json:"createdAt"` 13 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 14 15 } 15 16 16 17 func (t *FeedTrend) MarshalJSON() ([]byte, error) {
+4 -3
api/bsky/feedvote.go
··· 8 8 9 9 // schema: app.bsky.feed.vote 10 10 11 + // RECORDTYPE: FeedVote 11 12 type FeedVote struct { 12 - CreatedAt string `json:"createdAt"` 13 - Subject *comatprototypes.RepoStrongRef `json:"subject"` 14 - Direction string `json:"direction"` 13 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 14 + Direction string `json:"direction" cborgen:"direction"` 15 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 15 16 } 16 17 17 18 func (t *FeedVote) MarshalJSON() ([]byte, error) {
+4 -3
api/bsky/graphassertion.go
··· 6 6 7 7 // schema: app.bsky.graph.assertion 8 8 9 + // RECORDTYPE: GraphAssertion 9 10 type GraphAssertion struct { 10 - Subject *ActorRef `json:"subject"` 11 - CreatedAt string `json:"createdAt"` 12 - Assertion string `json:"assertion"` 11 + Assertion string `json:"assertion" cborgen:"assertion"` 12 + Subject *ActorRef `json:"subject" cborgen:"subject"` 13 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 13 14 } 14 15 15 16 func (t *GraphAssertion) MarshalJSON() ([]byte, error) {
+4 -3
api/bsky/graphconfirmation.go
··· 8 8 9 9 // schema: app.bsky.graph.confirmation 10 10 11 + // RECORDTYPE: GraphConfirmation 11 12 type GraphConfirmation struct { 12 - Assertion *comatprototypes.RepoStrongRef `json:"assertion"` 13 - CreatedAt string `json:"createdAt"` 14 - Originator *ActorRef `json:"originator"` 13 + Originator *ActorRef `json:"originator" cborgen:"originator"` 14 + Assertion *comatprototypes.RepoStrongRef `json:"assertion" cborgen:"assertion"` 15 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 15 16 } 16 17 17 18 func (t *GraphConfirmation) MarshalJSON() ([]byte, error) {
+3 -2
api/bsky/graphfollow.go
··· 6 6 7 7 // schema: app.bsky.graph.follow 8 8 9 + // RECORDTYPE: GraphFollow 9 10 type GraphFollow struct { 10 - Subject *ActorRef `json:"subject"` 11 - CreatedAt string `json:"createdAt"` 11 + Subject *ActorRef `json:"subject" cborgen:"subject"` 12 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 12 13 } 13 14 14 15 func (t *GraphFollow) MarshalJSON() ([]byte, error) {
+24 -24
api/bsky/graphgetAssertions.go
··· 9 9 10 10 // schema: app.bsky.graph.getAssertions 11 11 12 - type GraphGetAssertions_Output struct { 13 - Cursor string `json:"cursor"` 14 - Assertions []*GraphGetAssertions_Assertion `json:"assertions"` 15 - } 16 - 17 - func (t *GraphGetAssertions_Output) MarshalJSON() ([]byte, error) { 18 - out := make(map[string]interface{}) 19 - out["assertions"] = t.Assertions 20 - out["cursor"] = t.Cursor 21 - return json.Marshal(out) 22 - } 23 - 24 12 type GraphGetAssertions_Assertion struct { 25 - IndexedAt string `json:"indexedAt"` 26 - CreatedAt string `json:"createdAt"` 27 - Uri string `json:"uri"` 28 - Cid string `json:"cid"` 29 - Assertion string `json:"assertion"` 30 - Confirmation *GraphGetAssertions_Confirmation `json:"confirmation"` 31 - Author *ActorRef_WithInfo `json:"author"` 32 - Subject *ActorRef_WithInfo `json:"subject"` 13 + Confirmation *GraphGetAssertions_Confirmation `json:"confirmation" cborgen:"confirmation"` 14 + Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 15 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 17 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 18 + Uri string `json:"uri" cborgen:"uri"` 19 + Cid string `json:"cid" cborgen:"cid"` 20 + Assertion string `json:"assertion" cborgen:"assertion"` 33 21 } 34 22 35 23 func (t *GraphGetAssertions_Assertion) MarshalJSON() ([]byte, error) { ··· 46 34 } 47 35 48 36 type GraphGetAssertions_Confirmation struct { 49 - Uri string `json:"uri"` 50 - Cid string `json:"cid"` 51 - IndexedAt string `json:"indexedAt"` 52 - CreatedAt string `json:"createdAt"` 37 + Uri string `json:"uri" cborgen:"uri"` 38 + Cid string `json:"cid" cborgen:"cid"` 39 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 40 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 53 41 } 54 42 55 43 func (t *GraphGetAssertions_Confirmation) MarshalJSON() ([]byte, error) { ··· 58 46 out["createdAt"] = t.CreatedAt 59 47 out["indexedAt"] = t.IndexedAt 60 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 61 return json.Marshal(out) 62 62 } 63 63
+24 -24
api/bsky/graphgetFollowers.go
··· 9 9 10 10 // schema: app.bsky.graph.getFollowers 11 11 12 - type GraphGetFollowers_Output struct { 13 - Subject *GraphGetFollowers_Subject `json:"subject"` 14 - Cursor string `json:"cursor"` 15 - Followers []*GraphGetFollowers_Follower `json:"followers"` 16 - } 17 - 18 - func (t *GraphGetFollowers_Output) MarshalJSON() ([]byte, error) { 19 - out := make(map[string]interface{}) 20 - out["cursor"] = t.Cursor 21 - out["followers"] = t.Followers 22 - out["subject"] = t.Subject 23 - return json.Marshal(out) 24 - } 25 - 26 12 type GraphGetFollowers_Subject struct { 27 - DisplayName string `json:"displayName"` 28 - Did string `json:"did"` 29 - Declaration *SystemDeclRef `json:"declaration"` 30 - Handle string `json:"handle"` 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"` 31 17 } 32 18 33 19 func (t *GraphGetFollowers_Subject) MarshalJSON() ([]byte, error) { ··· 40 26 } 41 27 42 28 type GraphGetFollowers_Follower struct { 43 - IndexedAt string `json:"indexedAt"` 44 - Did string `json:"did"` 45 - Declaration *SystemDeclRef `json:"declaration"` 46 - Handle string `json:"handle"` 47 - DisplayName string `json:"displayName"` 48 - CreatedAt string `json:"createdAt"` 29 + Did string `json:"did" cborgen:"did"` 30 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 31 + 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"` 49 35 } 50 36 51 37 func (t *GraphGetFollowers_Follower) MarshalJSON() ([]byte, error) { ··· 56 42 out["displayName"] = t.DisplayName 57 43 out["handle"] = t.Handle 58 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 59 return json.Marshal(out) 60 60 } 61 61
+9 -9
api/bsky/graphgetFollows.go
··· 10 10 // schema: app.bsky.graph.getFollows 11 11 12 12 type GraphGetFollows_Output struct { 13 - Follows []*GraphGetFollows_Follow `json:"follows"` 14 - Subject *ActorRef_WithInfo `json:"subject"` 15 - Cursor string `json:"cursor"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Follows []*GraphGetFollows_Follow `json:"follows" cborgen:"follows"` 15 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 16 } 17 17 18 18 func (t *GraphGetFollows_Output) MarshalJSON() ([]byte, error) { ··· 24 24 } 25 25 26 26 type GraphGetFollows_Follow struct { 27 - Declaration *SystemDeclRef `json:"declaration"` 28 - Handle string `json:"handle"` 29 - DisplayName string `json:"displayName"` 30 - CreatedAt string `json:"createdAt"` 31 - IndexedAt string `json:"indexedAt"` 32 - Did string `json:"did"` 27 + Did string `json:"did" cborgen:"did"` 28 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 29 + Handle string `json:"handle" cborgen:"handle"` 30 + DisplayName string `json:"displayName" cborgen:"displayName"` 31 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 32 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 33 33 } 34 34 35 35 func (t *GraphGetFollows_Follow) MarshalJSON() ([]byte, error) {
+9 -9
api/bsky/graphgetMembers.go
··· 10 10 // schema: app.bsky.graph.getMembers 11 11 12 12 type GraphGetMembers_Output struct { 13 - Subject *ActorRef_WithInfo `json:"subject"` 14 - Cursor string `json:"cursor"` 15 - Members []*GraphGetMembers_Member `json:"members"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Members []*GraphGetMembers_Member `json:"members" cborgen:"members"` 15 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 16 } 17 17 18 18 func (t *GraphGetMembers_Output) MarshalJSON() ([]byte, error) { ··· 24 24 } 25 25 26 26 type GraphGetMembers_Member struct { 27 - Did string `json:"did"` 28 - Declaration *SystemDeclRef `json:"declaration"` 29 - Handle string `json:"handle"` 30 - DisplayName string `json:"displayName"` 31 - CreatedAt string `json:"createdAt"` 32 - IndexedAt string `json:"indexedAt"` 27 + DisplayName string `json:"displayName" cborgen:"displayName"` 28 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 29 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 30 + Did string `json:"did" cborgen:"did"` 31 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 32 + Handle string `json:"handle" cborgen:"handle"` 33 33 } 34 34 35 35 func (t *GraphGetMembers_Member) MarshalJSON() ([]byte, error) {
+9 -9
api/bsky/graphgetMemberships.go
··· 10 10 // schema: app.bsky.graph.getMemberships 11 11 12 12 type GraphGetMemberships_Membership struct { 13 - Handle string `json:"handle"` 14 - DisplayName string `json:"displayName"` 15 - CreatedAt string `json:"createdAt"` 16 - IndexedAt string `json:"indexedAt"` 17 - Did string `json:"did"` 18 - Declaration *SystemDeclRef `json:"declaration"` 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 19 } 20 20 21 21 func (t *GraphGetMemberships_Membership) MarshalJSON() ([]byte, error) { ··· 30 30 } 31 31 32 32 type GraphGetMemberships_Output struct { 33 - Subject *ActorRef_WithInfo `json:"subject"` 34 - Cursor string `json:"cursor"` 35 - Memberships []*GraphGetMemberships_Membership `json:"memberships"` 33 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 34 + Cursor string `json:"cursor" cborgen:"cursor"` 35 + Memberships []*GraphGetMemberships_Membership `json:"memberships" cborgen:"memberships"` 36 36 } 37 37 38 38 func (t *GraphGetMemberships_Output) MarshalJSON() ([]byte, error) {
+1 -1
api/bsky/notificationgetCount.go
··· 10 10 // schema: app.bsky.notification.getCount 11 11 12 12 type NotificationGetCount_Output struct { 13 - Count int64 `json:"count"` 13 + Count int64 `json:"count" cborgen:"count"` 14 14 } 15 15 16 16 func (t *NotificationGetCount_Output) MarshalJSON() ([]byte, error) {
+10 -10
api/bsky/notificationlist.go
··· 10 10 // schema: app.bsky.notification.list 11 11 12 12 type NotificationList_Output struct { 13 - Cursor string `json:"cursor"` 14 - Notifications []*NotificationList_Notification `json:"notifications"` 13 + Cursor string `json:"cursor" cborgen:"cursor"` 14 + Notifications []*NotificationList_Notification `json:"notifications" cborgen:"notifications"` 15 15 } 16 16 17 17 func (t *NotificationList_Output) MarshalJSON() ([]byte, error) { ··· 22 22 } 23 23 24 24 type NotificationList_Notification struct { 25 - Author *ActorRef_WithInfo `json:"author"` 26 - Reason string `json:"reason"` 27 - ReasonSubject string `json:"reasonSubject"` 28 - Record any `json:"record"` 29 - IsRead bool `json:"isRead"` 30 - IndexedAt string `json:"indexedAt"` 31 - Uri string `json:"uri"` 32 - Cid string `json:"cid"` 25 + IsRead bool `json:"isRead" cborgen:"isRead"` 26 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 27 + Uri string `json:"uri" cborgen:"uri"` 28 + Cid string `json:"cid" cborgen:"cid"` 29 + 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 33 } 34 34 35 35 func (t *NotificationList_Notification) MarshalJSON() ([]byte, error) {
+1 -1
api/bsky/notificationupdateSeen.go
··· 10 10 // schema: app.bsky.notification.updateSeen 11 11 12 12 type NotificationUpdateSeen_Input struct { 13 - SeenAt string `json:"seenAt"` 13 + SeenAt string `json:"seenAt" cborgen:"seenAt"` 14 14 } 15 15 16 16 func (t *NotificationUpdateSeen_Input) MarshalJSON() ([]byte, error) {
+2 -2
api/bsky/systemdeclRef.go
··· 7 7 // schema: app.bsky.system.declRef 8 8 9 9 type SystemDeclRef struct { 10 - Cid string `json:"cid"` 11 - ActorType string `json:"actorType"` 10 + Cid string `json:"cid" cborgen:"cid"` 11 + ActorType string `json:"actorType" cborgen:"actorType"` 12 12 } 13 13 14 14 func (t *SystemDeclRef) MarshalJSON() ([]byte, error) {
+2 -1
api/bsky/systemdeclaration.go
··· 6 6 7 7 // schema: app.bsky.system.declaration 8 8 9 + // RECORDTYPE: SystemDeclaration 9 10 type SystemDeclaration struct { 10 - ActorType string `json:"actorType"` 11 + ActorType string `json:"actorType" cborgen:"actorType"` 11 12 } 12 13 13 14 func (t *SystemDeclaration) MarshalJSON() ([]byte, error) {
+247
api/server/feedgen.go
··· 1 + package schemagen 2 + 3 + import ( 4 + "context" 5 + "fmt" 6 + "log" 7 + "time" 8 + 9 + "github.com/ipfs/go-cid" 10 + bsky "github.com/whyrusleeping/gosky/api/bsky" 11 + "github.com/whyrusleeping/gosky/repomgr" 12 + "go.opentelemetry.io/otel" 13 + "gorm.io/gorm" 14 + ) 15 + 16 + type FeedGenerator struct { 17 + db *gorm.DB 18 + 19 + readRecord func(context.Context, uint, cid.Cid) (any, error) 20 + } 21 + 22 + type FeedPost struct { 23 + gorm.Model 24 + Author uint 25 + RepostedBy uint 26 + TrendedBy uint 27 + Tid string 28 + Cid string 29 + UpCount int64 30 + ReplyCount int64 31 + RepostCount int64 32 + } 33 + 34 + type ActorInfo struct { 35 + gorm.Model 36 + User uint `gorm:"index"` 37 + Handle string 38 + Did string 39 + Name string 40 + Following int 41 + Followers int 42 + Posts int 43 + DeclRefCid string 44 + Type string 45 + } 46 + 47 + func NewFeedGenerator(db *gorm.DB) (*FeedGenerator, error) { 48 + db.AutoMigrate(&FeedPost{}) 49 + db.AutoMigrate(&ActorInfo{}) 50 + 51 + return &FeedGenerator{ 52 + db: db, 53 + }, nil 54 + } 55 + 56 + func (fg *FeedGenerator) catchup(ctx context.Context, evt *repomgr.RepoEvent) error { 57 + // TODO: catch up on events that happened since this event (in the event of a crash or downtime) 58 + return nil 59 + } 60 + 61 + type HydratedFeedItem struct { 62 + Uri string 63 + RepostedBy *bsky.ActorRef_WithInfo 64 + Record any 65 + ReplyCount int64 66 + RepostCount int64 67 + UpvoteCount int64 68 + DownvoteCount int64 69 + MyState *bsky.FeedGetAuthorFeed_MyState 70 + Cid string 71 + Author *bsky.ActorRef_WithInfo 72 + TrendedBy *bsky.ActorRef_WithInfo 73 + Embed *bsky.FeedEmbed 74 + IndexedAt string 75 + } 76 + 77 + func (fg *FeedGenerator) hydrateFeed(ctx context.Context, items []*FeedPost) ([]*HydratedFeedItem, error) { 78 + out := make([]*HydratedFeedItem, 0, len(items)) 79 + for _, it := range items { 80 + hit, err := fg.hydrateItem(ctx, it) 81 + if err != nil { 82 + return nil, err 83 + } 84 + 85 + out = append(out, hit) 86 + } 87 + 88 + return out, nil 89 + } 90 + 91 + func (fg *FeedGenerator) didForUser(ctx context.Context, user uint) (string, error) { 92 + // TODO: cache the shit out of this 93 + var ai ActorInfo 94 + if err := fg.db.First(&ai, "user = ?", user).Error; err != nil { 95 + return "", err 96 + } 97 + 98 + return ai.Handle, nil 99 + } 100 + 101 + func (fg *FeedGenerator) getActorRefInfo(ctx context.Context, user uint) (*bsky.ActorRef_WithInfo, error) { 102 + // TODO: cache the shit out of this too 103 + var ai ActorInfo 104 + if err := fg.db.First(&ai, "user = ?", user).Error; err != nil { 105 + return nil, err 106 + } 107 + 108 + out := bsky.ActorRef_WithInfo{ 109 + Did: ai.Did, 110 + Declaration: nil, //TODO: 111 + Handle: ai.Handle, 112 + DisplayName: ai.Name, 113 + } 114 + 115 + return &out, nil 116 + } 117 + 118 + func (fg *FeedGenerator) hydrateItem(ctx context.Context, item *FeedPost) (*HydratedFeedItem, error) { 119 + authorDid, err := fg.didForUser(ctx, item.Author) 120 + if err != nil { 121 + return nil, err 122 + } 123 + 124 + out := HydratedFeedItem{ 125 + Uri: "at://" + authorDid + "/" + item.Tid, 126 + ReplyCount: item.ReplyCount, 127 + RepostCount: item.RepostCount, 128 + UpvoteCount: item.UpCount, 129 + DownvoteCount: 0, 130 + Cid: item.Cid, 131 + IndexedAt: item.UpdatedAt.Format(time.RFC3339), 132 + } 133 + 134 + author, err := fg.getActorRefInfo(ctx, item.Author) 135 + if err != nil { 136 + return nil, err 137 + } 138 + 139 + out.Author = author 140 + 141 + if item.TrendedBy != 0 { 142 + tb, err := fg.getActorRefInfo(ctx, item.TrendedBy) 143 + if err != nil { 144 + return nil, err 145 + } 146 + 147 + out.TrendedBy = tb 148 + } 149 + 150 + if item.RepostedBy != 0 { 151 + rp, err := fg.getActorRefInfo(ctx, item.RepostedBy) 152 + if err != nil { 153 + return nil, err 154 + } 155 + 156 + out.RepostedBy = rp 157 + } 158 + 159 + rec, err := fg.readRecord(ctx, item.Author, item.RecCid) 160 + if err != nil { 161 + return nil, err 162 + } 163 + 164 + return &out, nil 165 + } 166 + 167 + func (fg *FeedGenerator) GetAuthorFeed(ctx context.Context, user uint, before string, limit int) ([]*HydratedFeedItem, error) { 168 + ctx, span := otel.Tracer("feedgen").Start(context.Background(), "GetAuthorFeed") 169 + defer span.End() 170 + 171 + // for memory efficiency, should probably return the actual type that goes out to the user... 172 + // bsky.FeedGetAuthorFeed_FeedItem 173 + 174 + var feed []*FeedPost 175 + if err := fg.db.Find(&feed, "author = ? OR reposted_by = ?", user, user).Error; err != nil { 176 + return nil, err 177 + } 178 + 179 + return fg.hydrateFeed(ctx, feed) 180 + } 181 + 182 + func (fg *FeedGenerator) HandleRepoEvent(evt *repomgr.RepoEvent) { 183 + ctx, span := otel.Tracer("feedgen").Start(context.Background(), "HandleRepoEvent") 184 + defer span.End() 185 + 186 + if err := fg.catchup(ctx, evt); err != nil { 187 + log.Println("failed to catch up on user repo changes, processing events off base: ", err) 188 + } 189 + 190 + fmt.Println("Handling Event!", evt.Kind) 191 + 192 + switch evt.Kind { 193 + case "createRecord": 194 + if err := fg.handleRecordCreate(ctx, evt); err != nil { 195 + log.Println("handle recordCreate: ", err) 196 + } 197 + case "initActor": 198 + if err := fg.handleInitActor(ctx, evt); err != nil { 199 + log.Println("handle initActor: ", err) 200 + } 201 + default: 202 + log.Println("unrecognized repo event type: ", evt.Kind) 203 + } 204 + 205 + } 206 + 207 + func (fg *FeedGenerator) handleInitActor(ctx context.Context, evt *repomgr.RepoEvent) error { 208 + ai := evt.ActorInfo 209 + if err := fg.db.Create(&ActorInfo{ 210 + User: evt.User, 211 + Handle: ai.Handle, 212 + Did: ai.Did, 213 + Name: ai.DisplayName, 214 + DeclRefCid: ai.DeclRefCid, 215 + Type: ai.Type, 216 + }).Error; err != nil { 217 + return err 218 + } 219 + 220 + return nil 221 + } 222 + 223 + func (fg *FeedGenerator) handleRecordCreate(ctx context.Context, evt *repomgr.RepoEvent) error { 224 + switch rec := evt.Record.(type) { 225 + case *bsky.FeedPost: 226 + fp := FeedPost{ 227 + Tid: evt.Rkey, 228 + Cid: evt.RecCid.String(), 229 + Author: evt.User, 230 + } 231 + if err := fg.db.Create(&fp).Error; err != nil { 232 + return err 233 + } 234 + 235 + if err := fg.addNewPostNotification(ctx, evt.User, fp.ID); err != nil { 236 + return err 237 + } 238 + return nil 239 + default: 240 + return fmt.Errorf("unrecognized record type: %T", rec) 241 + } 242 + } 243 + 244 + func (fg *FeedGenerator) addNewPostNotification(ctx context.Context, user uint, postid uint) error { 245 + // TODO: 246 + return nil 247 + }
+124 -5
api/server/handlers.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 + "bytes" 4 5 "context" 6 + "fmt" 5 7 "io" 6 8 9 + "github.com/ipfs/go-cid" 10 + cbg "github.com/whyrusleeping/cbor-gen" 7 11 comatprototypes "github.com/whyrusleeping/gosky/api/atproto" 8 12 appbskytypes "github.com/whyrusleeping/gosky/api/bsky" 9 13 ) ··· 33 37 } 34 38 35 39 func (s *Server) handleAppBskyFeedGetAuthorFeed(ctx context.Context, author string, before string, limit int) (*appbskytypes.FeedGetAuthorFeed_Output, error) { 36 - panic("not yet implemented") 40 + _, err := s.getUser(ctx) 41 + if err != nil { 42 + return nil, err 43 + } 44 + 45 + target, err := s.lookupUser(ctx, author) 46 + //target, err := s.lookupUserByHandle(ctx, author) 47 + if err != nil { 48 + return nil, err 49 + } 50 + 51 + feed, err := s.feedgen.GetAuthorFeed(ctx, target.ID, before, limit) 52 + if err != nil { 53 + return nil, err 54 + } 55 + 56 + var out appbskytypes.FeedGetAuthorFeed_Output 57 + for _, fi := range feed { 58 + out.Feed = append(out.Feed, &appbskytypes.FeedGetAuthorFeed_FeedItem{ 59 + Uri: fi.Uri, 60 + RepostedBy: fi.RepostedBy, 61 + Record: fi.Record, 62 + ReplyCount: fi.ReplyCount, 63 + RepostCount: fi.RepostCount, 64 + UpvoteCount: fi.UpvoteCount, 65 + DownvoteCount: 0, 66 + MyState: nil, // TODO: 67 + Cid: fi.Cid, 68 + Author: fi.Author, 69 + TrendedBy: fi.TrendedBy, 70 + Embed: nil, 71 + IndexedAt: fi.IndexedAt, 72 + }) 73 + } 74 + 75 + return &out, nil 37 76 } 38 77 39 78 func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context, depth int, uri string) (*appbskytypes.FeedGetPostThread_Output, error) { ··· 89 128 } 90 129 91 130 func (s *Server) handleComAtprotoAccountCreate(ctx context.Context, input *comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) { 92 - if err := s.db.Create(&User{ 131 + 132 + if err := validateEmail(input.Email); err != nil { 133 + return nil, err 134 + } 135 + 136 + if err := s.validateHandle(input.Handle); err != nil { 137 + return nil, err 138 + 139 + } 140 + 141 + u := User{ 93 142 Handle: input.Handle, 94 143 Password: input.Password, 95 144 RecoveryKey: input.RecoveryKey, 96 - }).Error; err != nil { 145 + Email: input.Email, 146 + } 147 + if err := s.db.Create(&u).Error; err != nil { 97 148 return nil, err 98 149 } 99 150 100 151 d, err := s.fakeDid.NewForHandle(input.Handle) 101 152 if err != nil { 153 + return nil, err 154 + } 155 + 156 + if err := s.repoman.InitNewActor(ctx, u.ID, u.Handle, u.DID, "", UserActorDeclCid, UserActorDeclType); err != nil { 102 157 return nil, err 103 158 } 104 159 ··· 148 203 if err != nil { 149 204 return nil, err 150 205 } 206 + 207 + var rec cbg.CBORMarshaler 208 + switch input.Collection { 209 + case "app.bsky.feed.post": 210 + rec = new(appbskytypes.FeedPost) 211 + default: 212 + return nil, fmt.Errorf("unsupported collection: %q", input.Collection) 213 + } 214 + 215 + // TODO: if we had a 'record' type receiver declaration in lexicon i could 216 + // codegen in a special handler for things that are supposed to be records 217 + // like this 218 + if err := convertRecordTo(input.Record, rec); err != nil { 219 + return nil, err 220 + } 221 + 222 + rkey, recid, err := s.repoman.CreateRecord(ctx, u.ID, input.Collection, rec) 223 + if err != nil { 224 + return nil, err 225 + } 226 + 227 + return &comatprototypes.RepoCreateRecord_Output{ 228 + Uri: "at://" + u.DID + "/" + rkey, 229 + Cid: recid.String(), 230 + }, nil 151 231 } 152 232 153 233 func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context, input *comatprototypes.RepoDeleteRecord_Input) error { ··· 175 255 } 176 256 177 257 func (s *Server) handleComAtprotoSessionCreate(ctx context.Context, input *comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) { 178 - panic("not yet implemented") 258 + u, err := s.lookupUserByHandle(ctx, input.Handle) 259 + if err != nil { 260 + return nil, err 261 + } 262 + 263 + if input.Password != u.Password { 264 + return nil, fmt.Errorf("invalid username or password") 265 + } 266 + 267 + tok, err := s.createAuthTokenForUser(ctx, input.Handle, u.DID) 268 + if err != nil { 269 + return nil, err 270 + } 271 + 272 + return &comatprototypes.SessionCreate_Output{ 273 + Handle: input.Handle, 274 + Did: u.DID, 275 + AccessJwt: tok.AccessJwt, 276 + RefreshJwt: tok.RefreshJwt, 277 + }, nil 179 278 } 180 279 181 280 func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error { ··· 191 290 } 192 291 193 292 func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context, did string, from string) (io.Reader, error) { 194 - panic("not yet implemented") 293 + var fromcid cid.Cid 294 + if from != "" { 295 + cc, err := cid.Decode(from) 296 + if err != nil { 297 + return nil, err 298 + } 299 + 300 + fromcid = cc 301 + } 302 + 303 + targetUser, err := s.lookupUser(ctx, did) 304 + if err != nil { 305 + return nil, err 306 + } 307 + 308 + buf := new(bytes.Buffer) 309 + if err := s.repoman.ReadRepo(ctx, targetUser.ID, fromcid, buf); err != nil { 310 + return nil, err 311 + } 312 + 313 + return buf, nil 195 314 } 196 315 197 316 func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context, did string) (*comatprototypes.SyncGetRoot_Output, error) {
+226 -14
api/server/server.go
··· 1 1 package schemagen 2 2 3 3 import ( 4 + "context" 4 5 "crypto/ecdsa" 5 6 "crypto/elliptic" 7 + "encoding/json" 6 8 "fmt" 9 + "net/mail" 7 10 "os" 11 + "strings" 12 + "time" 8 13 9 14 "github.com/golang-jwt/jwt" 10 15 "github.com/labstack/echo/v4" 11 16 "github.com/labstack/echo/v4/middleware" 12 17 jwk "github.com/lestrrat-go/jwx/jwk" 13 18 "github.com/whyrusleeping/gosky/carstore" 19 + "github.com/whyrusleeping/gosky/repomgr" 14 20 "gorm.io/gorm" 15 21 ) 16 22 17 23 type Server struct { 18 24 db *gorm.DB 19 25 cs *carstore.CarStore 26 + repoman *repomgr.RepoManager 27 + feedgen *FeedGenerator 20 28 signingKey []byte 21 29 30 + handleSuffix string 31 + 22 32 fakeDid *FakeDid 23 33 } 24 34 35 + const UserActorDeclCid = "bafyreid27zk7lbis4zw5fz4podbvbs4fc5ivwji3dmrwa6zggnj4bnd57u" 36 + const UserActorDeclType = "app.bsky.system.actorUser" 37 + 25 38 func NewServer(db *gorm.DB, cs *carstore.CarStore, kfile string) (*Server, error) { 39 + db.AutoMigrate(&User{}) 40 + 41 + serkey, err := loadKey(kfile) 42 + if err != nil { 43 + return nil, err 44 + } 45 + 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{ 54 + signingKey: serkey, 55 + db: db, 56 + cs: cs, 57 + repoman: repoman, 58 + feedgen: feedgen, 59 + fakeDid: NewFakeDid(db), 60 + handleSuffix: ".pdstest", 61 + }, nil 62 + 63 + } 64 + 65 + func loadKey(kfile string) ([]byte, error) { 26 66 kb, err := os.ReadFile(kfile) 27 67 if err != nil { 28 68 return nil, err ··· 37 77 if err := sk.Raw(&spk); err != nil { 38 78 return nil, err 39 79 } 40 - 41 - serkey := elliptic.Marshal(spk.Curve, spk.X, spk.Y) 42 - 43 - db.AutoMigrate(&User{}) 44 - 45 - return &Server{ 46 - signingKey: serkey, 47 - db: db, 48 - cs: cs, 49 - fakeDid: NewFakeDid(db), 50 - }, nil 80 + return elliptic.Marshal(spk.Curve, spk.X, spk.Y), nil 51 81 } 52 82 53 83 func (s *Server) RunAPI(listen string) error { 54 84 e := echo.New() 55 85 56 86 cfg := middleware.JWTConfig{ 57 - KeyFunc: s.getKey, 87 + Skipper: func(c echo.Context) bool { 88 + fmt.Println("skipper: ", c.Path()) 89 + switch c.Path() { 90 + case "/xrpc/com.atproto.account.create": 91 + return true 92 + case "/xrpc/com.atproto.session.create": 93 + return true 94 + default: 95 + return false 96 + } 97 + }, 98 + //KeyFunc: s.getKey, 58 99 SigningKey: s.signingKey, 59 100 } 60 101 ··· 62 103 fmt.Println("HANDLER ERROR: ", err) 63 104 } 64 105 65 - s.RegisterHandlersComAtproto(e.Group("")) 66 - s.RegisterHandlersAppBsky(e.Group("", middleware.JWTWithConfig(cfg))) 106 + e.Use(middleware.JWTWithConfig(cfg), s.userCheckMiddleware) 107 + s.RegisterHandlersComAtproto(e) 108 + s.RegisterHandlersAppBsky(e) 67 109 68 110 return e.Start(listen) 69 111 } ··· 73 115 Handle string 74 116 Password string 75 117 RecoveryKey string 118 + Email string 76 119 DID string 77 120 } 78 121 122 + func toTime(i interface{}) (time.Time, error) { 123 + ival, ok := i.(float64) 124 + if !ok { 125 + return time.Time{}, fmt.Errorf("invalid type for timestamp: %T", i) 126 + } 127 + 128 + return time.Unix(int64(ival), 0), nil 129 + } 130 + 131 + func (s *Server) checkTokenValidity(user *jwt.Token) (string, string, error) { 132 + claims, ok := user.Claims.(jwt.MapClaims) 133 + if !ok { 134 + return "", "", fmt.Errorf("bad claims table") 135 + } 136 + 137 + iat, ok := claims["iat"] 138 + if !ok { 139 + return "", "", fmt.Errorf("iat not set") 140 + } 141 + 142 + tiat, err := toTime(iat) 143 + if err != nil { 144 + return "", "", err 145 + } 146 + 147 + if tiat.After(time.Now()) { 148 + return "", "", fmt.Errorf("iat cannot be in the future") 149 + } 150 + 151 + exp, ok := claims["exp"] 152 + if !ok { 153 + return "", "", fmt.Errorf("exp not set") 154 + } 155 + 156 + texp, err := toTime(exp) 157 + if err != nil { 158 + return "", "", err 159 + } 160 + 161 + if texp.Before(time.Now()) { 162 + return "", "", fmt.Errorf("token expired") 163 + } 164 + 165 + did, ok := claims["sub"] 166 + if !ok { 167 + return "", "", fmt.Errorf("expected user did in subject") 168 + } 169 + 170 + didstr, ok := did.(string) 171 + if !ok { 172 + return "", "", fmt.Errorf("expected subject to be a string") 173 + } 174 + 175 + scope, ok := claims["scope"] 176 + if !ok { 177 + return "", "", fmt.Errorf("expected scope to be set") 178 + } 179 + 180 + scopestr, ok := scope.(string) 181 + if !ok { 182 + return "", "", fmt.Errorf("expected scope to be a string") 183 + } 184 + 185 + return scopestr, didstr, nil 186 + } 187 + 188 + func (s *Server) lookupUser(ctx context.Context, did string) (*User, error) { 189 + var didEntry FakeDidMapping 190 + if err := s.db.First(&didEntry, "did = ?", did).Error; err != nil { 191 + return nil, err 192 + } 193 + 194 + var u User 195 + if err := s.db.First(&u, "handle = ?", didEntry.Handle).Error; err != nil { 196 + return nil, err 197 + } 198 + 199 + return &u, nil 200 + } 201 + 202 + func (s *Server) lookupUserByHandle(ctx context.Context, handle string) (*User, error) { 203 + var didEntry FakeDidMapping 204 + if err := s.db.First(&didEntry, "handle = ?", handle).Error; err != nil { 205 + return nil, err 206 + } 207 + 208 + var u User 209 + if err := s.db.First(&u, "handle = ?", didEntry.Handle).Error; err != nil { 210 + if err == gorm.ErrRecordNotFound { 211 + return nil, fmt.Errorf("no such user with handle: %s", handle) 212 + } 213 + return nil, err 214 + } 215 + 216 + u.DID = didEntry.Did 217 + 218 + return &u, nil 219 + } 220 + 221 + func (s *Server) userCheckMiddleware(next echo.HandlerFunc) echo.HandlerFunc { 222 + return func(c echo.Context) error { 223 + ctx := c.Request().Context() 224 + 225 + user, ok := c.Get("user").(*jwt.Token) 226 + if !ok { 227 + return next(c) 228 + } 229 + 230 + scope, did, err := s.checkTokenValidity(user) 231 + if err != nil { 232 + return fmt.Errorf("invalid token: %w", err) 233 + } 234 + 235 + _ = scope 236 + 237 + u, err := s.lookupUser(ctx, did) 238 + if err != nil { 239 + return err 240 + } 241 + 242 + ctx = context.WithValue(ctx, "user", u) 243 + ctx = context.WithValue(ctx, "did", did) 244 + 245 + c.SetRequest(c.Request().WithContext(ctx)) 246 + return next(c) 247 + } 248 + } 249 + 79 250 func (s *Server) handleAuth(next echo.HandlerFunc) echo.HandlerFunc { 80 251 return func(c echo.Context) error { 81 252 authstr := c.Request().Header.Get("Authorization") ··· 90 261 91 262 return nil, nil 92 263 } 264 + 265 + func (s *Server) getUser(ctx context.Context) (*User, error) { 266 + u, ok := ctx.Value("user").(*User) 267 + if !ok { 268 + return nil, fmt.Errorf("auth required") 269 + } 270 + 271 + u.DID = ctx.Value("did").(string) 272 + 273 + return u, nil 274 + } 275 + 276 + func convertRecordTo(from any, to any) error { 277 + b, err := json.Marshal(from) 278 + if err != nil { 279 + return err 280 + } 281 + 282 + return json.Unmarshal(b, to) 283 + } 284 + 285 + func validateEmail(email string) error { 286 + _, err := mail.ParseAddress(email) 287 + if err != nil { 288 + return err 289 + } 290 + 291 + return nil 292 + } 293 + 294 + func (s *Server) validateHandle(handle string) error { 295 + if !strings.HasSuffix(handle, s.handleSuffix) { 296 + return fmt.Errorf("invalid handle") 297 + } 298 + 299 + if strings.Contains(strings.TrimSuffix(handle, s.handleSuffix), ".") { 300 + return fmt.Errorf("invalid handle") 301 + } 302 + 303 + return nil 304 + }
+4 -3
api/server/stubs.go
··· 10 10 "go.opentelemetry.io/otel" 11 11 ) 12 12 13 - func (s *Server) RegisterHandlersAppBsky(e *echo.Group) error { 13 + func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 14 14 e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene) 15 15 e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) 16 16 e.GET("/xrpc/app.bsky.actor.getSuggestions", s.HandleAppBskyActorGetSuggestions) ··· 407 407 return nil 408 408 } 409 409 410 - func (s *Server) RegisterHandlersComAtproto(e *echo.Group) error { 410 + func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 411 411 e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate) 412 412 e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 413 413 e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) ··· 744 744 if handleErr != nil { 745 745 return handleErr 746 746 } 747 - return c.JSON(200, out) 747 + 748 + return c.Stream(200, "application/octet-stream", out) 748 749 } 749 750 750 751 func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error {
+5 -5
carstore/repo_test.go
··· 104 104 t.Fatal(err) 105 105 } 106 106 107 - if err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 107 + if _, err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 108 108 Text: fmt.Sprintf("hey look its a tweet %s", time.Now()), 109 109 }); err != nil { 110 110 t.Fatal(err) ··· 134 134 func setupRepo(ctx context.Context, bs blockstore.Blockstore) (cid.Cid, error) { 135 135 nr := repo.NewRepo(ctx, bs) 136 136 137 - if err := nr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 137 + if _, err := nr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 138 138 Text: fmt.Sprintf("hey look its a tweet %s", time.Now()), 139 139 }); err != nil { 140 140 return cid.Undef, err ··· 184 184 b.Fatal(err) 185 185 } 186 186 187 - if err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 187 + if _, err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 188 188 Text: fmt.Sprintf("hey look its a tweet %s", time.Now()), 189 189 }); err != nil { 190 190 b.Fatal(err) ··· 226 226 b.Fatal(err) 227 227 } 228 228 229 - if err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 229 + if _, err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 230 230 Text: fmt.Sprintf("hey look its a tweet %s", time.Now()), 231 231 }); err != nil { 232 232 b.Fatal(err) ··· 263 263 b.Fatal(err) 264 264 } 265 265 266 - if err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 266 + if _, err := rr.CreateRecord(ctx, "app.bsky.feed.post", &api.PostRecord{ 267 267 Text: fmt.Sprintf("hey look its a tweet %s", time.Now()), 268 268 }); err != nil { 269 269 b.Fatal(err)
+85 -16
cmd/gosky/main.go
··· 10 10 "time" 11 11 12 12 "github.com/ipfs/go-cid" 13 + "github.com/polydawn/refmt/cbor" 14 + rejson "github.com/polydawn/refmt/json" 15 + "github.com/polydawn/refmt/shared" 13 16 cli "github.com/urfave/cli/v2" 14 17 api "github.com/whyrusleeping/gosky/api" 15 18 cliutil "github.com/whyrusleeping/gosky/cmd/gosky/util" ··· 118 121 119 122 resp, err := atp.RepoCreateRecord(context.TODO(), auth.Did, "app.bsky.feed.post", true, &api.PostRecord{ 120 123 Text: text, 121 - CreatedAt: time.Now().Format(time.RFC3339), 124 + CreatedAt: time.Now().Format("2006-01-02T15:04:05.000Z"), 122 125 }) 123 126 if err != nil { 124 127 return err ··· 440 443 441 444 var listAllPostsCmd = &cli.Command{ 442 445 Name: "list", 446 + Flags: []cli.Flag{ 447 + &cli.BoolFlag{ 448 + Name: "all", 449 + }, 450 + &cli.BoolFlag{ 451 + Name: "values", 452 + }, 453 + &cli.BoolFlag{ 454 + Name: "cids", 455 + }, 456 + }, 443 457 Action: func(cctx *cli.Context) error { 444 - atpc, err := cliutil.GetATPClient(cctx, true) 445 - if err != nil { 446 - return err 447 - } 448 458 449 - did := cctx.Args().First() 450 - if did == "" { 451 - did = atpc.C.Auth.Did 452 - } 453 - 459 + arg := cctx.Args().First() 454 460 ctx := context.TODO() 455 - repob, err := atpc.SyncGetRepo(ctx, did, nil) 456 - if err != nil { 457 - return err 461 + 462 + var repob []byte 463 + if strings.HasPrefix(arg, "did:") { 464 + atpc, err := cliutil.GetATPClient(cctx, true) 465 + if err != nil { 466 + return err 467 + } 468 + 469 + if arg == "" { 470 + arg = atpc.C.Auth.Did 471 + } 472 + 473 + rrb, err := atpc.SyncGetRepo(ctx, arg, nil) 474 + if err != nil { 475 + return err 476 + } 477 + repob = rrb 478 + } else { 479 + fb, err := os.ReadFile(arg) 480 + if err != nil { 481 + return err 482 + } 483 + 484 + repob = fb 458 485 } 459 486 460 487 rr, err := repo.ReadRepoFromCar(ctx, bytes.NewReader(repob)) ··· 462 489 return err 463 490 } 464 491 465 - if err := rr.ForEach(ctx, "app.bsky.feed.post", func(k string, v cid.Cid) error { 466 - if !strings.HasPrefix(k, "app.bsky.feed.post/") { 492 + collection := "app.bsky.feed.post" 493 + if cctx.Bool("all") { 494 + collection = "" 495 + } 496 + vals := cctx.Bool("values") 497 + cids := cctx.Bool("cids") 498 + 499 + if err := rr.ForEach(ctx, collection, func(k string, v cid.Cid) error { 500 + if !strings.HasPrefix(k, collection) { 467 501 return repo.ErrDoneIterating 468 502 } 469 503 470 - fmt.Println(k) 504 + fmt.Print(k) 505 + if cids { 506 + fmt.Println(" - ", v) 507 + } else { 508 + fmt.Println() 509 + } 510 + if vals { 511 + b, err := rr.Blockstore().Get(ctx, v) 512 + if err != nil { 513 + return err 514 + } 515 + 516 + convb, err := cborToJson(b.RawData()) 517 + if err != nil { 518 + return err 519 + } 520 + fmt.Println(string(convb)) 521 + } 471 522 return nil 472 523 }); err != nil { 473 524 return err ··· 476 527 return nil 477 528 }, 478 529 } 530 + 531 + func cborToJson(data []byte) ([]byte, error) { 532 + defer func() { 533 + if r := recover(); r != nil { 534 + fmt.Println("panic: ", r) 535 + } 536 + }() 537 + buf := new(bytes.Buffer) 538 + enc := rejson.NewEncoder(buf, rejson.EncodeOptions{}) 539 + 540 + dec := cbor.NewDecoder(cbor.DecodeOptions{}, bytes.NewReader(data)) 541 + err := shared.TokenPump{dec, enc}.Run() 542 + if err != nil { 543 + return nil, err 544 + } 545 + 546 + return buf.Bytes(), nil 547 + }
+3 -3
cmd/pds/main.go
··· 12 12 app := cli.NewApp() 13 13 14 14 app.Action = func(cctx *cli.Context) error { 15 - db, err := gorm.Open(sqlite.Open("pds.db")) 15 + db, err := gorm.Open(sqlite.Open("pdsdata/pds.db")) 16 16 if err != nil { 17 17 return err 18 18 } 19 19 20 - carstdb, err := gorm.Open(sqlite.Open("carstore.db")) 20 + carstdb, err := gorm.Open(sqlite.Open("pdsdata/carstore.db")) 21 21 if err != nil { 22 22 return err 23 23 } 24 24 25 - cs, err := carstore.NewCarStore(carstdb, "carstore") 25 + cs, err := carstore.NewCarStore(carstdb, "pdsdata/carstore") 26 26 if err != nil { 27 27 return err 28 28 }
+20
gen/main.go
··· 3 3 import ( 4 4 cbg "github.com/whyrusleeping/cbor-gen" 5 5 "github.com/whyrusleeping/gosky/api" 6 + atproto "github.com/whyrusleeping/gosky/api/atproto" 7 + bsky "github.com/whyrusleeping/gosky/api/bsky" 6 8 mst "github.com/whyrusleeping/gosky/mst" 7 9 "github.com/whyrusleeping/gosky/repo" 8 10 ) ··· 17 19 } 18 20 19 21 if err := cbg.WriteMapEncodersToFile("api/cbor_gen.go", "api", api.PostRecord{}, api.PostEntity{}, api.PostRef{}, api.ReplyRef{}, api.TextSlice{}); err != nil { 22 + panic(err) 23 + } 24 + 25 + // RECORDTYPE: GraphFollow 26 + // RECORDTYPE: GraphAssertion 27 + // RECORDTYPE: GraphConfirmation 28 + // RECORDTYPE: SystemDeclaration 29 + // RECORDTYPE: ActorProfile 30 + // RECORDTYPE: FeedVote 31 + // RECORDTYPE: FeedTrend 32 + // RECORDTYPE: FeedRepost 33 + // RECORDTYPE: FeedPost 34 + 35 + if err := cbg.WriteMapEncodersToFile("api/bsky/cbor_gen.go", "schemagen", bsky.FeedPost{}, bsky.FeedRepost{}, bsky.FeedTrend{}, bsky.FeedVote{}, bsky.FeedPost_Entity{}, bsky.FeedPost_ReplyRef{}, bsky.FeedPost_TextSlice{}); err != nil { 36 + panic(err) 37 + } 38 + 39 + if err := cbg.WriteMapEncodersToFile("api/atproto/cbor_gen.go", "schemagen", atproto.RepoStrongRef{}); err != nil { 20 40 panic(err) 21 41 } 22 42 }
+53 -46
lex/gen.go
··· 48 48 id string 49 49 defName string 50 50 defMap map[string]*ExtDef 51 + record bool 51 52 52 53 Type string `json:"type"` 53 54 Key string `json:"key"` ··· 87 88 walk = func(name string, ts *TypeSchema, record bool) { 88 89 if ts == nil { 89 90 panic(fmt.Sprintf("nil type schema in %q (%s)", name, s.ID)) 91 + } 90 92 91 - } 93 + ts.record = record 92 94 ts.prefix = prefix 93 95 ts.id = s.ID 94 96 ts.defMap = defMap ··· 102 104 } 103 105 104 106 for childname, val := range ts.Properties { 105 - walk(name+"_"+strings.Title(childname), val, false) 107 + walk(name+"_"+strings.Title(childname), val, record) 106 108 } 107 109 108 110 if ts.Items != nil { 109 - walk(name+"_Elem", ts.Items, false) 111 + walk(name+"_Elem", ts.Items, record) 110 112 } 111 113 112 114 if ts.Input != nil { ··· 115 117 panic(fmt.Sprintf("strange input type def in %s", s.ID)) 116 118 } 117 119 } else { 118 - walk(name+"_Input", ts.Input.Schema, false) 120 + walk(name+"_Input", ts.Input.Schema, record) 119 121 } 120 122 } 121 123 ··· 125 127 panic(fmt.Sprintf("strange output type def in %s", s.ID)) 126 128 } 127 129 } else { 128 - walk(name+"_Output", ts.Output.Schema, false) 130 + walk(name+"_Output", ts.Output.Schema, record) 129 131 } 130 132 } 131 133 132 134 if ts.Type == "record" { 133 - walk(name, ts.Record, false) 135 + walk(name, ts.Record, true) 134 136 } 135 137 136 138 } ··· 223 225 tps := s.AllTypes(prefix, defmap) 224 226 225 227 for _, ot := range tps { 228 + fmt.Println("TYPE: ", ot.Name) 226 229 if err := ot.Type.WriteType(ot.Name, buf); err != nil { 227 230 return err 228 231 } ··· 525 528 } 526 529 fmt.Fprintf(w, ")\n\n") 527 530 528 - 529 531 ssets := make(map[string][]*Schema) 530 532 for _, s := range schemas { 531 533 var pref string ··· 539 541 return fmt.Errorf("no matching prefix for schema %q", s.ID) 540 542 } 541 543 542 - ssets[pref] = append(ssets[pref], s) 544 + ssets[pref] = append(ssets[pref], s) 543 545 544 546 } 545 547 546 548 for _, p := range prefixes { 547 549 ss := ssets[p] 548 550 549 - fmt.Fprintf(w, "func (s *Server) RegisterHandlers%s(e *echo.Echo) error {\n", idToTitle(p)) 550 - for _, s := range ss { 551 + fmt.Fprintf(w, "func (s *Server) RegisterHandlers%s(e *echo.Echo) error {\n", idToTitle(p)) 552 + for _, s := range ss { 551 553 552 - main, ok := s.Defs["main"] 553 - if !ok { 554 - return fmt.Errorf("schema %q has no main", s.ID) 555 - } 554 + main, ok := s.Defs["main"] 555 + if !ok { 556 + return fmt.Errorf("schema %q has no main", s.ID) 557 + } 558 + 559 + var verb string 560 + switch main.Type { 561 + case "query": 562 + verb = "GET" 563 + case "procedure": 564 + verb = "POST" 565 + default: 566 + continue 567 + } 556 568 557 - var verb string 558 - switch main.Type { 559 - case "query": 560 - verb = "GET" 561 - case "procedure": 562 - verb = "POST" 563 - default: 564 - continue 569 + fmt.Fprintf(w, "e.%s(\"/xrpc/%s\", s.Handle%s)\n", verb, s.ID, idToTitle(s.ID)) 565 570 } 566 571 567 - fmt.Fprintf(w, "e.%s(\"/xrpc/%s\", s.Handle%s)\n", verb, s.ID, idToTitle(s.ID)) 568 - } 572 + fmt.Fprintf(w, "return nil\n}\n\n") 569 573 570 - fmt.Fprintf(w, "return nil\n}\n\n") 571 - 572 - for _, s := range ss { 574 + for _, s := range ss { 573 575 574 - var prefix string 575 - for k := range impmap { 576 - if strings.HasPrefix(s.ID, k) { 577 - prefix = k 578 - break 576 + var prefix string 577 + for k := range impmap { 578 + if strings.HasPrefix(s.ID, k) { 579 + prefix = k 580 + break 581 + } 579 582 } 580 - } 581 583 582 - main, ok := s.Defs["main"] 583 - if !ok { 584 - return fmt.Errorf("schema %q doesnt have a main def", s.ID) 585 - } 584 + main, ok := s.Defs["main"] 585 + if !ok { 586 + return fmt.Errorf("schema %q doesnt have a main def", s.ID) 587 + } 586 588 587 - if main.Type == "procedure" || main.Type == "query" { 588 - fname := idToTitle(s.ID) 589 - tname := nameFromID(s.ID, prefix) 590 - impname := importNameForPrefix(prefix) 591 - if err := main.WriteRPCHandler(w, fname, tname, impname); err != nil { 592 - return err 589 + if main.Type == "procedure" || main.Type == "query" { 590 + fname := idToTitle(s.ID) 591 + tname := nameFromID(s.ID, prefix) 592 + impname := importNameForPrefix(prefix) 593 + if err := main.WriteRPCHandler(w, fname, tname, impname); err != nil { 594 + return err 595 + } 593 596 } 594 597 } 595 598 } 596 - } 597 599 598 600 return nil 599 601 } ··· 699 701 return err 700 702 } 701 703 `, intname) 702 - paramtypes = append(paramtypes, "body " + intname ) 704 + paramtypes = append(paramtypes, "body "+intname) 703 705 params = append(params, "&body") 704 706 case "application/cbor": 705 707 fmt.Fprintf(w, "body := c.Request().Body\n") ··· 862 864 return nil 863 865 } 864 866 867 + if ts.record { 868 + fmt.Fprintf(w, "// RECORDTYPE: %s\n", name) 869 + } 870 + 865 871 fmt.Fprintf(w, "type %s struct {\n", name) 866 872 867 873 for k, v := range ts.Properties { ··· 872 878 return err 873 879 } 874 880 875 - fmt.Fprintf(w, "\t%s %s `json:\"%s\"`\n", goname, tname, k) 881 + fmt.Fprintf(w, "\t%s %s `json:\"%s\" cborgen:\"%s\"`\n", goname, tname, k, k) 882 + 876 883 } 877 884 fmt.Fprintf(w, "}\n\n") 878 885
+9 -5
repo/repo.go
··· 108 108 MarshalCBOR(w io.Writer) error 109 109 } 110 110 111 - func (r *Repo) CreateRecord(ctx context.Context, nsid string, rec CborMarshaler) error { 111 + func (r *Repo) Blockstore() blockstore.Blockstore { 112 + return r.bs 113 + } 114 + 115 + func (r *Repo) CreateRecord(ctx context.Context, nsid string, rec CborMarshaler) (cid.Cid, error) { 112 116 r.dirty = true 113 117 t, err := r.getMst(ctx) 114 118 if err != nil { 115 - return fmt.Errorf("failed to get mst: %w", err) 119 + return cid.Undef, fmt.Errorf("failed to get mst: %w", err) 116 120 } 117 121 118 122 k, err := r.cst.Put(ctx, rec) 119 123 if err != nil { 120 - return err 124 + return cid.Undef, err 121 125 } 122 126 123 127 nmst, err := t.Add(ctx, nsid+"/"+NextTID(), k, -1) 124 128 if err != nil { 125 - return fmt.Errorf("mst.Add failed: %w", err) 129 + return cid.Undef, fmt.Errorf("mst.Add failed: %w", err) 126 130 } 127 131 128 132 r.mst = nmst 129 - return nil 133 + return k, nil 130 134 } 131 135 132 136 func (r *Repo) Commit(ctx context.Context) (cid.Cid, error) {
+3
testscripts/cleanup.sh
··· 1 + #!/bin/bash 2 + rm -rf pdsdata 3 + mkdir -p pdsdata/carstore
+7
testscripts/pdstest.sh
··· 1 + #!/bin/bash 2 + set -e 3 + set -x 4 + ./gosky --pds="http://localhost:4989" newAccount test@foo.com testman.pdstest password > test.auth 5 + ./gosky --pds="http://localhost:4989" --auth="test.auth" post "cats are really cool and the best" 6 + ./gosky --pds="http://localhost:4989" --auth="test.auth" post "paul frazee needs to buy a sweater" 7 +