From e755cb093508b430ef31adebe63e11c7fc4e01d9 Mon Sep 17 00:00:00 2001 From: David Buchanan Date: Sun, 8 Dec 2024 10:49:39 +0000 Subject: [PATCH] hack: generate #account events on updateHandle --- docs/ACCOUNTS.md | 2 +- src/millipds/service.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/ACCOUNTS.md b/docs/ACCOUNTS.md index fffd294..305650b 100644 --- a/docs/ACCOUNTS.md +++ b/docs/ACCOUNTS.md @@ -70,7 +70,7 @@ You'll probably run into some error messages because the relay doesn't know abou curl --json '{"hostname": "https://pds.example.com"}' "https://bsky.network/xrpc/com.atproto.sync.requestCrawl" ``` -Now we need to emit an `#identity` event (probably an `#account` event too but millipds doesn't do that yet!!!). This can be done by heading to your settings in `bsky.app` and "changing" your handle to the value it already is (e.g. `bob.example.com`) - this tells millipds to emit an `#identity` event. (I'll make this part more automatic in the future) +Now we need to emit an `#identity` event. This can be done by heading to your settings in `bsky.app` and "changing" your handle to the value it already is (e.g. `bob.example.com`) - this tells millipds to emit an `#identity` event. (I'll make this part more automatic in the future) (Note: as a temp workaround, this will also generate an `#account` event, which is maybe-necessary. unsure! In the future this should be triggered by account creation itself, probably.) The relay should be paying attention now, but maybe not the appview. To make the appview start indexing your posts, I *think* you need to create a bluesky profile record first, which can be done by setting your display name and/or bio (e.g. from `bsky.app`). diff --git a/src/millipds/service.py b/src/millipds/service.py index 01ca034..303c2cb 100644 --- a/src/millipds/service.py +++ b/src/millipds/service.py @@ -244,6 +244,26 @@ async def identity_update_handle(request: web.Request): (firehose_seq, 0, firehose_bytes) # TODO: put sensible timestamp here... ) await atproto_repo.firehose_broadcast(request, (firehose_seq, firehose_bytes)) + + # temp hack: #account events shouldn't really be generated here + with get_db(request).new_con() as con: + # TODO: refactor to avoid duplicated logic between here and apply_writes + firehose_seq = con.execute("SELECT IFNULL(MAX(seq), 0) + 1 FROM firehose").fetchone()[0] + firehose_bytes = cbrrr.encode_dag_cbor({ + "t": "#account", + "op": 1 + }) + cbrrr.encode_dag_cbor({ + "seq": firehose_seq, + "did": request["authed_did"], + "time": util.iso_string_now(), + "active": True + }) + con.execute( + "INSERT INTO firehose (seq, timestamp, msg) VALUES (?, ?, ?)", + (firehose_seq, 0, firehose_bytes) # TODO: put sensible timestamp here... + ) + await atproto_repo.firehose_broadcast(request, (firehose_seq, firehose_bytes)) + return web.Response()