fork of indigo with slightly nicer lexgen
0
fork

Configure Feed

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

client tweaks

+8 -21
+2 -9
atproto/client/admin_auth.go
··· 3 import ( 4 "encoding/base64" 5 "net/http" 6 - 7 - "github.com/bluesky-social/indigo/atproto/syntax" 8 ) 9 10 type AdminAuth struct { ··· 16 return AdminAuth{basicAuthHeader: header} 17 } 18 19 - func (a *AdminAuth) DoWithAuth(req *http.Request, httpClient *http.Client) (*http.Response, error) { 20 req.Header.Set("Authorization", a.basicAuthHeader) 21 - return httpClient.Do(req) 22 - } 23 - 24 - // Admin bearer token auth does not involve an account DID 25 - func (a *AdminAuth) AccountDID() syntax.DID { 26 - return "" 27 }
··· 3 import ( 4 "encoding/base64" 5 "net/http" 6 ) 7 8 type AdminAuth struct { ··· 14 return AdminAuth{basicAuthHeader: header} 15 } 16 17 + func (a *AdminAuth) DoWithAuth(c *http.Client, req *http.Request) (*http.Response, error) { 18 req.Header.Set("Authorization", a.basicAuthHeader) 19 + return c.Do(req) 20 }
+1 -1
atproto/client/api_client.go
··· 114 115 var resp *http.Response 116 if c.Auth != nil { 117 - resp, err = c.Auth.DoWithAuth(httpReq, c.HTTPClient) 118 } else { 119 resp, err = c.HTTPClient.Do(httpReq) 120 }
··· 114 115 var resp *http.Response 116 if c.Auth != nil { 117 + resp, err = c.Auth.DoWithAuth(c.HTTPClient, httpReq) 118 } else { 119 resp, err = c.HTTPClient.Do(httpReq) 120 }
+1 -1
atproto/client/auth_method.go
··· 5 ) 6 7 type AuthMethod interface { 8 - DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) 9 }
··· 5 ) 6 7 type AuthMethod interface { 8 + DoWithAuth(c *http.Client, req *http.Request) (*http.Response, error) 9 }
+1 -7
atproto/client/examples_test.go
··· 2 3 import ( 4 "context" 5 - "encoding/json" 6 "fmt" 7 8 appbsky "github.com/bluesky-social/indigo/api/bsky" ··· 21 params := map[string]string{ 22 "actor": "atproto.com", 23 } 24 - b, err := c.Get(ctx, endpoint, params) 25 - if err != nil { 26 - panic(err) 27 - } 28 - 29 var profile appbsky.ActorDefs_ProfileViewDetailed 30 - if err := json.Unmarshal(*b, &profile); err != nil { 31 panic(err) 32 } 33
··· 2 3 import ( 4 "context" 5 "fmt" 6 7 appbsky "github.com/bluesky-social/indigo/api/bsky" ··· 20 params := map[string]string{ 21 "actor": "atproto.com", 22 } 23 var profile appbsky.ActorDefs_ProfileViewDetailed 24 + if err := c.Get(ctx, endpoint, params, &profile); err != nil { 25 panic(err) 26 } 27
+3 -3
atproto/client/refresh_auth.go
··· 24 // TODO: 25 //func NewRefreshAuth(pdsHost, accountIdentifier, password string) (*RefreshAuth, error) { 26 27 - func (a *RefreshAuth) DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) { 28 req.Header.Set("Authorization", "Bearer "+a.AccessToken) 29 // XXX: check response. if it is 403, because access token is expired, then take a lock and do a refresh 30 // TODO: when doing a refresh request, copy at least the User-Agent header from httpReq, and re-use httpClient 31 - return c.Do(httpReq) 32 } 33 34 // updates the client with the new auth method ··· 49 } 50 51 if out.Active != nil && *out.Active == false { 52 - return nil, fmt.Errorf("account is disabled: %s", out.Status) 53 } 54 55 ra := RefreshAuth{
··· 24 // TODO: 25 //func NewRefreshAuth(pdsHost, accountIdentifier, password string) (*RefreshAuth, error) { 26 27 + func (a *RefreshAuth) DoWithAuth(c *http.Client, req *http.Request) (*http.Response, error) { 28 req.Header.Set("Authorization", "Bearer "+a.AccessToken) 29 // XXX: check response. if it is 403, because access token is expired, then take a lock and do a refresh 30 // TODO: when doing a refresh request, copy at least the User-Agent header from httpReq, and re-use httpClient 31 + return c.Do(req) 32 } 33 34 // updates the client with the new auth method ··· 49 } 50 51 if out.Active != nil && *out.Active == false { 52 + return nil, fmt.Errorf("account is disabled: %v", out.Status) 53 } 54 55 ra := RefreshAuth{