diff --git a/src/millipds/service.py b/src/millipds/service.py index c8566a2..5c28f91 100644 --- a/src/millipds/service.py +++ b/src/millipds/service.py @@ -379,9 +379,13 @@ async def identity_update_handle(request: web.Request): handle = req_json.get("handle") if handle is None: raise web.HTTPBadRequest(text="missing or invalid handle") - # TODO: actually validate it, and update the db!!! + # TODO: actually validate it # (I'm writing this half-baked version just so I can send firehose #identity events) with get_db(request).new_con() as con: + con.execute( + "UPDATE user SET handle = ? WHERE did = ?", + (handle, request["authed_did"]), + ) # TODO: refactor to avoid duplicated logic between here and apply_writes firehose_seq = con.execute( "SELECT IFNULL(MAX(seq), 0) + 1 FROM firehose" diff --git a/tests/integration_test.py b/tests/integration_test.py index 49f0648..9518947 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -493,3 +493,19 @@ async def test_deleteSession(s, pds_host): headers={"Authorization": "Bearer " + refresh_token}, ) as r: assert r.status != 200 + +async def test_updateHandle(s, pds_host, auth_headers): + async with s.post( + pds_host + "/xrpc/com.atproto.identity.updateHandle", + headers=auth_headers, + json={ "handle": "juliet.test" }, + ) as r: + assert r.status == 200 + + async with s.get( + pds_host + "/xrpc/com.atproto.repo.describeRepo", + params={ "repo": TEST_DID }, + ) as r: + assert r.status == 200 + r = await r.json() + assert r["handle"] == "juliet.test"