Skip to content

Commit

Permalink
Merge pull request #240 from jovfer/hotfix/fix_forwarding_msg
Browse files Browse the repository at this point in the history
Align Forward message with RFC 0094: msg must be JSON dict, not a string
  • Loading branch information
andrewwhitehead authored Jan 29, 2020
2 parents 0000f92 + bdf046f commit cba01dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

0 comments on commit cba01dd

Please sign in to comment.