this repo has no description
0
fork

Configure Feed

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

api: remove unused deprecated helpers

-194
-137
api/atproto.go
··· 1 1 package api 2 2 3 3 import ( 4 - "bytes" 5 4 "context" 6 5 7 6 "github.com/bluesky-social/indigo/xrpc" ··· 11 10 C *xrpc.Client 12 11 } 13 12 14 - type TID string 15 - 16 - type CreateSessionResp struct { 17 - AccessJwt string `json:"accessJwt"` 18 - RefreshJwt string `json:"refreshJwt"` 19 - Handle string `json:"handle"` 20 - Did string `json:"did"` 21 - } 22 - 23 13 const ( 24 14 encJson = "application/json" 25 15 ) 26 16 27 - func (atp *ATProto) CreateSession(ctx context.Context, handle, password string) (*CreateSessionResp, error) { 28 - body := map[string]string{ 29 - "handle": handle, 30 - "password": password, 31 - } 32 - 33 - var resp CreateSessionResp 34 - if err := atp.C.Do(ctx, xrpc.Procedure, encJson, "com.atproto.session.create", nil, body, &resp); err != nil { 35 - return nil, err 36 - } 37 - 38 - return &resp, nil 39 - } 40 - 41 17 type CreateAccountResp struct { 42 18 AccessJwt string `json:"accessJwt"` 43 19 RefreshJwt string `json:"refreshJwt"` ··· 64 40 65 41 return &resp, nil 66 42 } 67 - 68 - type CreateRecordResponse struct { 69 - Uri string `json:"uri"` 70 - Cid string `json:"cid"` 71 - } 72 - 73 - func (atp *ATProto) RepoCreateRecord(ctx context.Context, did, collection string, validate bool, rec interface{}) (*CreateRecordResponse, error) { 74 - body := map[string]interface{}{ 75 - "$type": collection, 76 - "did": did, 77 - "collection": collection, 78 - "validate": validate, 79 - "record": rec, 80 - } 81 - 82 - var out CreateRecordResponse 83 - if err := atp.C.Do(ctx, xrpc.Procedure, encJson, "com.atproto.repo.createRecord", nil, body, &out); err != nil { 84 - return nil, err 85 - } 86 - 87 - return &out, nil 88 - } 89 - 90 - func (atp *ATProto) SyncGetRepo(ctx context.Context, did string, from *string) ([]byte, error) { 91 - params := map[string]interface{}{ 92 - "did": did, 93 - } 94 - if from != nil { 95 - params["from"] = *from 96 - } 97 - 98 - out := new(bytes.Buffer) 99 - if err := atp.C.Do(ctx, xrpc.Query, encJson, "com.atproto.sync.getRepo", params, nil, out); err != nil { 100 - return nil, err 101 - } 102 - 103 - return out.Bytes(), nil 104 - } 105 - 106 - func (atp *ATProto) SyncGetRoot(ctx context.Context, did string) (string, error) { 107 - params := map[string]interface{}{ 108 - "did": did, 109 - } 110 - 111 - var out struct { 112 - Root string `json:"root"` 113 - } 114 - if err := atp.C.Do(ctx, xrpc.Query, encJson, "com.atproto.sync.getRoot", params, nil, &out); err != nil { 115 - return "", err 116 - } 117 - 118 - return out.Root, nil 119 - } 120 - 121 - func (atp *ATProto) HandleResolve(ctx context.Context, handle string) (string, error) { 122 - params := map[string]interface{}{ 123 - "handle": handle, 124 - } 125 - 126 - var out struct { 127 - Did string `json:"did"` 128 - } 129 - if err := atp.C.Do(ctx, xrpc.Query, encJson, "com.atproto.handle.resolve", params, nil, &out); err != nil { 130 - return "", err 131 - } 132 - 133 - return out.Did, nil 134 - 135 - } 136 - 137 - func (atp *ATProto) SessionRefresh(ctx context.Context) (*xrpc.AuthInfo, error) { 138 - var out xrpc.AuthInfo 139 - if err := atp.C.Do(ctx, xrpc.Procedure, encJson, "com.atproto.session.refresh", nil, nil, &out); err != nil { 140 - return nil, err 141 - } 142 - 143 - return &out, nil 144 - } 145 - 146 - type RecordResponse[T any] struct { 147 - Uri string `json:"uri"` 148 - Cid string `json:"cid"` 149 - Value T `json:"value"` 150 - } 151 - 152 - func RepoGetRecord[T any](atp *ATProto, ctx context.Context, user string, collection string, rkey string) (*RecordResponse[T], error) { 153 - params := map[string]interface{}{ 154 - "user": user, 155 - "collection": collection, 156 - "rkey": rkey, 157 - } 158 - 159 - var out RecordResponse[T] 160 - if err := atp.C.Do(ctx, xrpc.Query, encJson, "com.atproto.repo.getRecord", params, nil, &out); err != nil { 161 - return nil, err 162 - } 163 - 164 - return &out, nil 165 - } 166 - 167 - func (atp *ATProto) RepoDeleteRecord(ctx context.Context, did, collection, rkey string) error { 168 - body := map[string]interface{}{ 169 - "did": did, 170 - "collection": collection, 171 - "rkey": rkey, 172 - } 173 - 174 - if err := atp.C.Do(ctx, xrpc.Procedure, encJson, "com.atproto.repo.deleteRecord", nil, body, nil); err != nil { 175 - return err 176 - } 177 - 178 - return nil 179 - }
-57
api/bsky.go
··· 28 28 Uri string `json:"uri"` 29 29 Cid string `json:"cid"` 30 30 } 31 - 32 - type GetTimelineResp struct { 33 - Cursor string `json:"cursor"` 34 - Feed []FeedItem `json:"feed"` 35 - } 36 - 37 - type FeedItem struct { 38 - Uri string `json:"uri"` 39 - Cid string `json:"cid"` 40 - Author *User `json:"author"` 41 - RepostedBy *User `json:"repostedBy"` 42 - MyState *MyState `json:"myState"` 43 - Record interface{} `json:"record"` 44 - } 45 - 46 - type MyState struct { 47 - Repost string `json:"repost"` 48 - Upvote string `json:"upvote"` 49 - Downvote string `json:"downvote"` 50 - } 51 - 52 - type Declaration struct { 53 - Cid string `json:"cid"` 54 - ActorType string `json:"actorType"` 55 - } 56 - 57 - type User struct { 58 - Did string `json:"did"` 59 - Handle string `json:"handle"` 60 - DisplayName string `json:"displayName"` 61 - Declaration *Declaration `json:"declaration"` 62 - } 63 - 64 - type GSADeclaration struct { 65 - Cid string `json:"cid"` 66 - ActorType string `json:"actorType"` 67 - } 68 - 69 - type GetSuggestionsActor struct { 70 - Did string `json:"did"` 71 - Declaration *GSADeclaration `json:"declaration"` 72 - Handle string `json:"handle"` 73 - DisplayName string `json:"displayName"` 74 - Description string `json:"description"` 75 - IndexedAt string `json:"indexedAt"` 76 - } 77 - 78 - type GetSuggestionsResp struct { 79 - Cursor string `json:"cursor"` 80 - Actors []GetSuggestionsActor `json:"actors"` 81 - } 82 - 83 - type GetFollowsResp struct { 84 - Subject *User `json:"subject"` 85 - Cursor string `json:"cursor"` 86 - Follows []User `json:"follows"` 87 - }