Skip to content

Commit

Permalink
feat: allow prefix when sending exn message (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal authored Oct 15, 2024
1 parent c9d35f9 commit e8bc173
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/keria/peer/exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_post(req, rep, name):
Args:
req (Request): falcon HTTP request object
rep (Response): falcon HTTP response object
name (str): human readable alias for AID context
name (str): human readable name or prefix for AID context
---
summary: Post an exchange message for an identifier.
description: This endpoint posts an exchange message to a specific named identifier.
Expand Down Expand Up @@ -85,9 +85,9 @@ def on_post(req, rep, name):
body = req.get_media()

# Get the hab
hab = agent.hby.habByName(name)
hab = agent.hby.habs[name] if name in agent.hby.habs else agent.hby.habByName(name)
if hab is None:
raise falcon.HTTPNotFound(description=f"alias={name} is not a valid reference to an identifier")
raise falcon.HTTPNotFound(description=f"{name} is not a valid reference to an identifier")

# Get the exn, sigs, additional attachments and recipients from the request
ked = httping.getRequiredParam(body, "exn")
Expand Down
8 changes: 8 additions & 0 deletions tests/peer/test_exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ def test_exchange_end(helpers):
assert len(agent.exchanges) == 1

doist.recur(deeds=deeds)
assert len(agent.exchanges) == 0

# Use prefix instead of alias to send again
res = client.simulate_post(path="/identifiers/EHgwVwQT15OJvilVvW57HE4w0-GPs_Stj2OFoAHZSysY/exchanges", json=body)
assert res.status_code == 202
assert res.json == cexn.ked
assert len(agent.exchanges) == 1

doist.recur(deeds=deeds)
assert len(agent.exchanges) == 0
agent.exnseeker.index(cexn.said)

Expand Down

0 comments on commit e8bc173

Please sign in to comment.