From 82cdadae80dbfdac792e2aeb21eda1824a2c1e29 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 23 Nov 2015 16:33:09 -0800 Subject: [PATCH] check welcome message 'send' too --- src/wormhole/blocking/transcribe.py | 2 ++ src/wormhole/twisted/transcribe.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/wormhole/blocking/transcribe.py b/src/wormhole/blocking/transcribe.py index 2e88c5b..86f24c2 100644 --- a/src/wormhole/blocking/transcribe.py +++ b/src/wormhole/blocking/transcribe.py @@ -68,6 +68,8 @@ class Channel: timeout=self._timeout) r.raise_for_status() resp = r.json() + if "welcome" in resp: + self._handle_welcome(resp["welcome"]) self._add_inbound_messages(resp["messages"]) def get_first_of(self, phases): diff --git a/src/wormhole/twisted/transcribe.py b/src/wormhole/twisted/transcribe.py index 6ea9e41..044d217 100644 --- a/src/wormhole/twisted/transcribe.py +++ b/src/wormhole/twisted/transcribe.py @@ -106,6 +106,11 @@ class Channel: "phase": phase, "body": hexlify(msg).decode("ascii")} d = post_json(self._agent, self._relay_url+"add", payload) + def _maybe_handle_welcome(resp): + if "welcome" in resp: + self._handle_welcome(resp["welcome"]) + return resp + d.addCallback(_maybe_handle_welcome) d.addCallback(lambda resp: self._add_inbound_messages(resp["messages"])) return d