馃Ы Clean up old and stale atcr.io tags and manifests
767 B
31 lines
1package main
2
3import (
4 "context"
5 "fmt"
6
7 "github.com/bluesky-social/indigo/atproto/identity"
8 "github.com/bluesky-social/indigo/atproto/syntax"
9)
10
11// resolveIdentity resolves an atproto identifier (handle or DID) to a DID and
12// PDS endpoint using the indigo identity directory.
13func resolveIdentity(ctx context.Context, h string) (did, pds string, err error) {
14 p, err := syntax.ParseAtIdentifier(h)
15 if err != nil {
16 return "", "", fmt.Errorf("invalid identifier %q: %w", h, err)
17 }
18
19 dir := identity.DefaultDirectory()
20 id, err := dir.Lookup(ctx, p)
21 if err != nil {
22 return "", "", fmt.Errorf("lookup %q: %w", h, err)
23 }
24
25 pds = id.PDSEndpoint()
26 if pds == "" {
27 return "", "", fmt.Errorf("no PDS endpoint for %q", h)
28 }
29
30 return id.DID.String(), pds, nil
31}