For unbind poke IS used during binding of 3PID
This changes the behaviour from using the server specified trusted identity server to using the IS that used during the binding of the 3PID, if known. This is the behaviour specified by MSC1915.pull/4982/head
parent
1666c0696a
commit
9fbbc3d9e5
|
@ -159,21 +159,47 @@ class IdentityHandler(BaseHandler):
|
||||||
Deferred[bool]: True on success, otherwise False if the identity
|
Deferred[bool]: True on success, otherwise False if the identity
|
||||||
server doesn't support unbinding
|
server doesn't support unbinding
|
||||||
"""
|
"""
|
||||||
logger.debug("unbinding threepid %r from %s", threepid, mxid)
|
id_servers = yield self.store.get_id_servers_user_bound(
|
||||||
if not self.trusted_id_servers:
|
user_id=mxid,
|
||||||
logger.warn("Can't unbind threepid: no trusted ID servers set in config")
|
medium=threepid["medium"],
|
||||||
|
address=threepid["address"],
|
||||||
|
)
|
||||||
|
|
||||||
|
# We don't know where to unbind, so we don't have a choice but to return
|
||||||
|
if not id_servers:
|
||||||
defer.returnValue(False)
|
defer.returnValue(False)
|
||||||
|
|
||||||
# We don't track what ID server we added 3pids on (perhaps we ought to)
|
changed = True
|
||||||
# but we assume that any of the servers in the trusted list are in the
|
for id_server in id_servers:
|
||||||
# same ID server federation, so we can pick any one of them to send the
|
changed &= yield self.try_unbind_threepid_with_id_server(
|
||||||
# deletion request to.
|
mxid, threepid, id_server,
|
||||||
id_server = next(iter(self.trusted_id_servers))
|
)
|
||||||
|
|
||||||
|
defer.returnValue(changed)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def try_unbind_threepid_with_id_server(self, mxid, threepid, id_server):
|
||||||
|
"""Removes a binding from an identity server
|
||||||
|
|
||||||
|
Args:
|
||||||
|
mxid (str): Matrix user ID of binding to be removed
|
||||||
|
threepid (dict): Dict with medium & address of binding to be removed
|
||||||
|
id_server (str): Identity server to unbind from
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
SynapseError: If we failed to contact the identity server
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Deferred[bool]: True on success, otherwise False if the identity
|
||||||
|
server doesn't support unbinding
|
||||||
|
"""
|
||||||
url = "https://%s/_matrix/identity/api/v1/3pid/unbind" % (id_server,)
|
url = "https://%s/_matrix/identity/api/v1/3pid/unbind" % (id_server,)
|
||||||
content = {
|
content = {
|
||||||
"mxid": mxid,
|
"mxid": mxid,
|
||||||
"threepid": threepid,
|
"threepid": {
|
||||||
|
"medium": threepid["medium"],
|
||||||
|
"address": threepid["address"],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# we abuse the federation http client to sign the request, but we have to send it
|
# we abuse the federation http client to sign the request, but we have to send it
|
||||||
|
|
Loading…
Reference in New Issue