Skip to content

Commit

Permalink
Merge pull request #40 from notjuliet/main
Browse files Browse the repository at this point in the history
update db with updateHandle
  • Loading branch information
DavidBuchanan314 authored Jan 9, 2025
2 parents ae955db + 649f8d3 commit c649185
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/millipds/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit c649185

Please sign in to comment.