tangled
alpha
login
or
join now
bnewbold.net
/
cobalt
13
fork
atom
go scratch code for atproto
13
fork
atom
overview
issues
pulls
pipelines
fix more atclient pkg renames
bnewbold.net
5 months ago
bcc971ce
c99f4f1c
+11
-11
6 changed files
expand all
collapse all
unified
split
atproto
pdsclient
pdsclient.go
cmd
glot
publish.go
pull.go
status.go
unpublish.go
slinky
main.go
+4
-4
atproto/pdsclient/pdsclient.go
···
13
13
)
14
14
15
15
type PDSClient struct {
16
16
-
*client.APIClient
16
16
+
*atclient.APIClient
17
17
18
18
AccountDID syntax.DID
19
19
}
···
63
63
func (pc *PDSClient) UploadBlob(ctx context.Context, mimeType string, input io.Reader) (*atdata.Blob, error) {
64
64
65
65
endpoint := syntax.NSID("com.atproto.repo.uploadBlob")
66
66
-
req := client.NewAPIRequest(http.MethodPost, endpoint, input)
66
66
+
req := atclient.NewAPIRequest(http.MethodPost, endpoint, input)
67
67
req.Headers.Set("Accept", "application/json")
68
68
req.Headers.Set("Content-Type", mimeType)
69
69
···
74
74
defer resp.Body.Close()
75
75
76
76
if !(resp.StatusCode >= 200 && resp.StatusCode < 300) {
77
77
-
var eb client.ErrorBody
77
77
+
var eb atclient.ErrorBody
78
78
if err := json.NewDecoder(resp.Body).Decode(&eb); err != nil {
79
79
-
return nil, &client.APIError{StatusCode: resp.StatusCode}
79
79
+
return nil, &atclient.APIError{StatusCode: resp.StatusCode}
80
80
}
81
81
return nil, eb.APIError(resp.StatusCode)
82
82
}
+2
-2
cmd/glot/publish.go
···
78
78
79
79
cdir := identity.DefaultDirectory()
80
80
// TODO: could defer actual login until later?
81
81
-
c, err := client.LoginWithPassword(ctx, cdir, *atid, pass, "", nil)
81
81
+
c, err := atclient.LoginWithPassword(ctx, cdir, *atid, pass, "", nil)
82
82
if err != nil {
83
83
return nil
84
84
}
···
214
214
return nil
215
215
}
216
216
217
217
-
func publishSchema(ctx context.Context, c *client.APIClient, nsid syntax.NSID, schemaJSON json.RawMessage) error {
217
217
+
func publishSchema(ctx context.Context, c *atclient.APIClient, nsid syntax.NSID, schemaJSON json.RawMessage) error {
218
218
219
219
d, err := atdata.UnmarshalJSON(schemaJSON)
220
220
if err != nil {
+1
-1
cmd/glot/pull.go
···
154
154
if err != nil {
155
155
return err
156
156
}
157
157
-
c := client.NewAPIClient(ident.PDSEndpoint())
157
157
+
c := atclient.NewAPIClient(ident.PDSEndpoint())
158
158
159
159
cursor := ""
160
160
for {
+1
-1
cmd/glot/status.go
···
199
199
if err != nil {
200
200
return err
201
201
}
202
202
-
c := client.NewAPIClient(ident.PDSEndpoint())
202
202
+
c := atclient.NewAPIClient(ident.PDSEndpoint())
203
203
204
204
cursor := ""
205
205
for {
+2
-2
cmd/glot/unpublish.go
···
53
53
54
54
cdir := identity.DefaultDirectory()
55
55
// TODO: could defer actual login until later?
56
56
-
c, err := client.LoginWithPassword(ctx, cdir, *atid, pass, "", nil)
56
56
+
c, err := atclient.LoginWithPassword(ctx, cdir, *atid, pass, "", nil)
57
57
if err != nil {
58
58
return nil
59
59
}
···
83
83
return nil
84
84
}
85
85
86
86
-
func unpublishSchema(ctx context.Context, c *client.APIClient, nsid syntax.NSID) error {
86
86
+
func unpublishSchema(ctx context.Context, c *atclient.APIClient, nsid syntax.NSID) error {
87
87
88
88
resp, err := comatproto.RepoDeleteRecord(ctx, c, &comatproto.RepoDeleteRecord_Input{
89
89
Collection: schemaNSID.String(),
+1
-1
cmd/slinky/main.go
···
80
80
slog.Info("enumerating accounts", "collection", collection)
81
81
defer close(tasks)
82
82
83
83
-
c := client.NewAPIClient(cmd.String("relay-host"))
83
83
+
c := atclient.NewAPIClient(cmd.String("relay-host"))
84
84
c.Headers.Set("User-Agent", userAgent())
85
85
// TODO: robust HTTP client (retries, longer timeout)
86
86