From acfde0e81b5c1122c7f5709094545fdf7e5465bc Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 9 Mar 2022 16:58:46 +0000 Subject: [PATCH 1/3] Allow modules to store already existing 3PID associations --- synapse/module_api/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index c42eeedd87ae..e854f8fd6fcb 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -1274,6 +1274,24 @@ async def check_username(self, username: str) -> None: """ await self._registration_handler.check_username(username) + async def store_remote_3pid_association( + self, user_id: str, medium: str, address: str, id_server: str + ) -> None: + """Stores an existing association between a user ID and a third-party identifier. + + The association must already exist on the remote identity server. + + Added in Synapse v1.55.0. + + Args: + user_id: The user ID that's been associated with the 3PID. + medium: The medium of the 3PID (current supported values are "msisdn" and + "email"). + address: The address of the 3PID. + id_server: The identity server the 3PID association has been registered on. + """ + await self._store.add_user_bound_threepid(user_id, medium, address, id_server) + class PublicRoomListManager: """Contains methods for adding to, removing from and querying whether a room From 4849974769a1cb089ab9a000466ab0fe862c6d83 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 9 Mar 2022 17:16:42 +0000 Subject: [PATCH 2/3] Changelog --- changelog.d/12195.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12195.feature diff --git a/changelog.d/12195.feature b/changelog.d/12195.feature new file mode 100644 index 000000000000..e8bcb950a1c6 --- /dev/null +++ b/changelog.d/12195.feature @@ -0,0 +1 @@ +Allow modules to store already existing 3PID associations. From c828999165ac81bacc699bf60c9b48d238a5bfaf Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Mon, 21 Mar 2022 15:54:21 +0000 Subject: [PATCH 3/3] Incorporate review --- synapse/module_api/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index e854f8fd6fcb..bcd4f05664e8 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -659,7 +659,8 @@ def register_device( def record_user_external_id( self, auth_provider_id: str, remote_user_id: str, registered_user_id: str ) -> defer.Deferred: - """Record a mapping from an external user id to a mxid + """Record a mapping between an external user id from a single sign-on provider + and a mxid. Added in Synapse v1.9.0. @@ -1281,7 +1282,7 @@ async def store_remote_3pid_association( The association must already exist on the remote identity server. - Added in Synapse v1.55.0. + Added in Synapse v1.56.0. Args: user_id: The user ID that's been associated with the 3PID. @@ -1289,6 +1290,12 @@ async def store_remote_3pid_association( "email"). address: The address of the 3PID. id_server: The identity server the 3PID association has been registered on. + This should only be the domain (or IP address, optionally with the port + number) for the identity server. This will be used to reach out to the + identity server using HTTPS (unless specified otherwise by Synapse's + configuration) when attempting to unbind the third-party identifier. + + """ await self._store.add_user_bound_threepid(user_id, medium, address, id_server)