@@ -219,28 +219,31 @@ async def bind_threepid(
219219 data = json_decoder .decode (e .msg ) # XXX WAT?
220220 return data
221221
222- async def try_unbind_threepid (self , mxid : str , threepid : dict ) -> bool :
223- """Attempt to remove a 3PID from an identity server, or if one is not provided, all
224- identity servers we're aware the binding is present on
222+ async def try_unbind_threepid (
223+ self , mxid : str , medium : str , address : str , id_server : Optional [str ]
224+ ) -> bool :
225+ """Attempt to remove a 3PID from one or more identity servers.
225226
226227 Args:
227228 mxid: Matrix user ID of binding to be removed
228- threepid: Dict with medium & address of binding to be
229- removed, and an optional id_server.
229+ medium: The medium of the third-party ID.
230+ address: The address of the third-party ID.
231+ id_server: An identity server to attempt to unbind from. If None,
232+ attempt to remove the association from all identity servers
233+ known to potentially have it.
230234
231235 Raises:
232- SynapseError: If we failed to contact the identity server
236+ SynapseError: If we failed to contact one or more identity servers.
233237
234238 Returns:
235- True on success, otherwise False if the identity
236- server doesn't support unbinding (or no identity server found to
237- contact).
239+ True on success, otherwise False if the identity server doesn't
240+ support unbinding (or no identity server to contact was found).
238241 """
239- if threepid . get ( " id_server" ) :
240- id_servers = [threepid [ " id_server" ] ]
242+ if id_server :
243+ id_servers = [id_server ]
241244 else :
242245 id_servers = await self .store .get_id_servers_user_bound (
243- user_id = mxid , medium = threepid [ "medium" ] , address = threepid [ "address" ]
246+ mxid , medium , address
244247 )
245248
246249 # We don't know where to unbind, so we don't have a choice but to return
@@ -249,20 +252,21 @@ async def try_unbind_threepid(self, mxid: str, threepid: dict) -> bool:
249252
250253 changed = True
251254 for id_server in id_servers :
252- changed &= await self .try_unbind_threepid_with_id_server (
253- mxid , threepid , id_server
255+ changed &= await self ._try_unbind_threepid_with_id_server (
256+ mxid , medium , address , id_server
254257 )
255258
256259 return changed
257260
258- async def try_unbind_threepid_with_id_server (
259- self , mxid : str , threepid : dict , id_server : str
261+ async def _try_unbind_threepid_with_id_server (
262+ self , mxid : str , medium : str , address : str , id_server : str
260263 ) -> bool :
261264 """Removes a binding from an identity server
262265
263266 Args:
264267 mxid: Matrix user ID of binding to be removed
265- threepid: Dict with medium & address of binding to be removed
268+ medium: The medium of the third-party ID
269+ address: The address of the third-party ID
266270 id_server: Identity server to unbind from
267271
268272 Raises:
@@ -286,7 +290,7 @@ async def try_unbind_threepid_with_id_server(
286290
287291 content = {
288292 "mxid" : mxid ,
289- "threepid" : {"medium" : threepid [ " medium" ] , "address" : threepid [ " address" ] },
293+ "threepid" : {"medium" : medium , "address" : address },
290294 }
291295
292296 # we abuse the federation http client to sign the request, but we have to send it
@@ -319,12 +323,7 @@ async def try_unbind_threepid_with_id_server(
319323 except RequestTimedOutError :
320324 raise SynapseError (500 , "Timed out contacting identity server" )
321325
322- await self .store .remove_user_bound_threepid (
323- user_id = mxid ,
324- medium = threepid ["medium" ],
325- address = threepid ["address" ],
326- id_server = id_server ,
327- )
326+ await self .store .remove_user_bound_threepid (mxid , medium , address , id_server )
328327
329328 return changed
330329
0 commit comments