···
"github.com/bluesky-social/indigo/atproto/syntax"
···
syntax.NSID("app.bsky.labeler.service"): true,
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))
···
if err := hs.store.Create(&Record{
Collection: string(uri.Collection()),
Key: string(uri.RecordKey()),
-
Data: json.RawMessage(*rec),
···
+
appbsky "github.com/bluesky-social/indigo/api/bsky"
"github.com/bluesky-social/indigo/atproto/syntax"
···
syntax.NSID("app.bsky.labeler.service"): true,
+
type bskycbor interface {
+
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))
···
+
switch uri.Collection() {
+
case syntax.NSID("app.bsky.actor.profile"):
+
out = appbsky.ActorProfile{}
+
case syntax.NSID("app.bsky.feed.generator"):
+
out = appbsky.FeedGenerator{}
+
case syntax.NSID("app.bsky.labeler.service"):
+
out = appbsky.LabelerService{}
+
model, ok := out.(bskycbor)
+
return errors.New("collection model cannot unmarshal CBOR")
+
if err := model.UnmarshalCBOR(bytes.NewReader(*rec)); err != nil {
+
return fmt.Errorf("error cbor unmarshaling: %w", err)
+
body, err := json.Marshal(model)
+
return fmt.Errorf("error json marshaling: %w", err)
if err := hs.store.Create(&Record{
Collection: string(uri.Collection()),
Key: string(uri.RecordKey()),
+
Data: json.RawMessage(body),