Track IS used to bind 3PIDs

This will then be used to know which IS to default to when unbinding the
threepid.
This commit is contained in:
Erik Johnston 2019-04-01 10:16:13 +01:00
parent 215c15d049
commit 1666c0696a
3 changed files with 119 additions and 0 deletions

View file

@ -132,6 +132,14 @@ class IdentityHandler(BaseHandler):
}
)
logger.debug("bound threepid %r to %s", creds, mxid)
# Remember where we bound the threepid
yield self.store.add_user_bound_threepid(
user_id=mxid,
medium=data["medium"],
address=data["address"],
id_server=id_server,
)
except CodeMessageException as e:
data = json.loads(e.msg) # XXX WAT?
defer.returnValue(data)
@ -188,6 +196,13 @@ 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,
)
except HttpResponseException as e:
if e.code in (400, 404, 501,):
# The remote server probably doesn't support unbinding (yet)