Skip to content

Commit

Permalink
subscribe.py: handle missing record block
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Jan 7, 2025
1 parent 061d385 commit b301524
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

if __name__ == '__main__':
assert len(sys.argv) <= 3
host = sys.argv[1] if len(sys.argv) >= 2 else 'bgs.bsky-sandbox.dev'
host = sys.argv[1] if len(sys.argv) >= 2 else 'bsky.network'
scheme = 'http' if host.split(':')[0] == 'localhost' else 'https'
client = Client(f'{scheme}://{host}')
kwargs = {'cursor': sys.argv[2]} if len(sys.argv) == 3 else {}
Expand All @@ -33,9 +33,11 @@
if blocks:
blocks = {block.cid: block for block in blocks}
for op in payload.get('ops', []):
record = blocks[op['cid']].decoded if op['cid'] else ''
record = ''
if block := blocks.get(op['cid']):
record = block.decoded
print(' ', op['action'], op['path'], record,
file=sys.stdout, flush=True)

print()
# break
break

0 comments on commit b301524

Please sign in to comment.