···
11
+
appbsky "github.com/bluesky-social/indigo/api/bsky"
"github.com/bluesky-social/indigo/atproto/syntax"
···
syntax.NSID("app.bsky.labeler.service"): true,
50
+
type bskycbor interface {
51
+
UnmarshalCBOR(io.Reader) error
func (hs *HandlerService) HandleUpsert(ctx context.Context, repo string, rev string, path string, rec *[]byte, cid *cid.Cid, action Action) error {
uri, err := syntax.ParseATURI(fmt.Sprintf("at://%s/%s", repo, path))
···
66
+
switch uri.Collection() {
67
+
case syntax.NSID("app.bsky.actor.profile"):
68
+
out = appbsky.ActorProfile{}
69
+
case syntax.NSID("app.bsky.feed.generator"):
70
+
out = appbsky.FeedGenerator{}
71
+
case syntax.NSID("app.bsky.labeler.service"):
72
+
out = appbsky.LabelerService{}
75
+
model, ok := out.(bskycbor)
77
+
return errors.New("collection model cannot unmarshal CBOR")
80
+
if err := model.UnmarshalCBOR(bytes.NewReader(*rec)); err != nil {
81
+
return fmt.Errorf("error cbor unmarshaling: %w", err)
84
+
body, err := json.Marshal(model)
86
+
return fmt.Errorf("error json marshaling: %w", err)
if err := hs.store.Create(&Record{
Collection: string(uri.Collection()),
Key: string(uri.RecordKey()),
63
-
Data: json.RawMessage(*rec),
95
+
Data: json.RawMessage(body),