summary refs log tree commit diff
path: root/synapse/handlers/identity.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/handlers/identity.py')
-rw-r--r--synapse/handlers/identity.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py
index 3ffdb45bef..6255d3ffed 100644
--- a/synapse/handlers/identity.py
+++ b/synapse/handlers/identity.py
@@ -169,12 +169,6 @@ class IdentityHandler(BaseHandler):
         # deletion request to.
         id_server = next(iter(self.trusted_id_servers))
 
-        # if we have a rewrite rule set for the identity server,
-        # apply it now.
-        if id_server in self.rewrite_identity_server_urls:
-            id_server = self.rewrite_identity_server_urls[id_server]
-
-        url = "https://%s/_matrix/identity/api/v1/3pid/unbind" % (id_server,)
         content = {
             "mxid": mxid,
             "threepid": threepid,
@@ -191,6 +185,15 @@ class IdentityHandler(BaseHandler):
             content=content,
             destination_is=id_server,
         )
+        # if we have a rewrite rule set for the identity server,
+        # apply it now.
+        #
+        # Note that destination_is has to be the real id_server, not
+        # the server we connect to.
+        if id_server in self.rewrite_identity_server_urls:
+            id_server = self.rewrite_identity_server_urls[id_server]
+
+        url = "https://%s/_matrix/identity/api/v1/3pid/unbind" % (id_server,)
         try:
             yield self.http_client.post_json_get_json(
                 url,