this repo has no description
0
fork

Configure Feed

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

trust (for now) ops in events (#460)

authored by

Whyrusleeping and committed by
GitHub
4876fc41 86038367

+26 -1
+26 -1
backfill/backfill.go
··· 441 441 ) 442 442 } 443 443 444 + const trust = true 445 + 446 + func (bf *Backfiller) getRecord(ctx context.Context, r *repo.Repo, op *atproto.SyncSubscribeRepos_RepoOp) (cid.Cid, typegen.CBORMarshaler, error) { 447 + if trust { 448 + if op.Cid == nil { 449 + return cid.Undef, nil, fmt.Errorf("op had no cid set") 450 + } 451 + 452 + c := (cid.Cid)(*op.Cid) 453 + blk, err := r.Blockstore().Get(ctx, c) 454 + if err != nil { 455 + return cid.Undef, nil, err 456 + } 457 + 458 + rec, err := lexutil.CborDecodeValue(blk.RawData()) 459 + if err != nil { 460 + return cid.Undef, nil, fmt.Errorf("failed to decode value: %w", err) 461 + } 462 + 463 + return c, rec, nil 464 + } else { 465 + return r.GetRecord(ctx, op.Path) 466 + } 467 + } 468 + 444 469 func (bf *Backfiller) HandleEvent(ctx context.Context, evt *atproto.SyncSubscribeRepos_Commit) error { 445 470 r, err := repo.ReadRepoFromCar(ctx, bytes.NewReader(evt.Blocks)) 446 471 if err != nil { ··· 451 476 for _, op := range evt.Ops { 452 477 switch op.Action { 453 478 case "create", "update": 454 - cc, rec, err := r.GetRecord(ctx, op.Path) 479 + cc, rec, err := bf.getRecord(ctx, r, op) 455 480 if err != nil { 456 481 return fmt.Errorf("getting record failed (%s,%s): %w", op.Action, op.Path, err) 457 482 }