summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-04-02 11:16:57 +0100
committerErik Johnston <erik@matrix.org>2019-04-02 11:20:09 +0100
commit24232514bfdd476b037052889d81a6651062446d (patch)
tree5936760bc9bb2124b2e45703c39f72ae5023aab2 /synapse/handlers
parentFixup docstrings (diff)
downloadsynapse-24232514bfdd476b037052889d81a6651062446d.tar.xz
Remove threepid binding if id server returns 400/404/501
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/identity.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py
index 3eb112bf9d..22469486d7 100644
--- a/synapse/handlers/identity.py
+++ b/synapse/handlers/identity.py
@@ -227,23 +227,24 @@ class IdentityHandler(BaseHandler):
                 content,
                 headers,
             )
-
-            yield self.store.remove_user_bound_threepid(
-                user_id=mxid,
-                medium=threepid["medium"],
-                address=threepid["address"],
-                id_server=id_server,
-            )
+            changed = True
         except HttpResponseException as e:
+            changed = False
             if e.code in (400, 404, 501,):
                 # The remote server probably doesn't support unbinding (yet)
                 logger.warn("Received %d response while unbinding threepid", e.code)
-                defer.returnValue(False)
             else:
                 logger.error("Failed to unbind threepid on identity server: %s", e)
                 raise SynapseError(502, "Failed to contact identity server")
 
-        defer.returnValue(True)
+        yield self.store.remove_user_bound_threepid(
+            user_id=mxid,
+            medium=threepid["medium"],
+            address=threepid["address"],
+            id_server=id_server,
+        )
+
+        defer.returnValue(changed)
 
     @defer.inlineCallbacks
     def requestEmailToken(self, id_server, email, client_secret, send_attempt, **kwargs):