Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Forward message with RFC 0094: msg must be JSON dict, not a string #240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aries_cloudagent/protocols/routing/messages/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Meta:
message_type = FORWARD
schema_class = "ForwardSchema"

def __init__(self, *, to: str = None, msg: str = None, **kwargs):
def __init__(self, *, to: str = None, msg: dict = None, **kwargs):
"""
Initialize forward message object.

Expand All @@ -41,4 +41,4 @@ class Meta:
model_class = Forward

to = fields.Str(required=True)
msg = fields.Str(required=True)
msg = fields.Dict(required=True)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_serialize(self, message_schema_dump):

class TestForwardSchema(TestCase):
def test_make_model(self):
message = Forward(to="to", msg="msg")
message = Forward(to="to", msg={"some": "msg"})
data = message.serialize()
model_instance = Forward.deserialize(data)
assert isinstance(model_instance, Forward)
1 change: 1 addition & 0 deletions aries_cloudagent/transport/pack_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ async def pack(
if routing_keys:
recip_keys = recipient_keys
for router_key in routing_keys:
message = json.loads(message.decode("utf-8"))
fwd_msg = Forward(to=recip_keys[0], msg=message)
# Forwards are anon packed
recip_keys = [router_key]
Expand Down