From e18f727db0374c5a9a9b0dde30fe7c33f02cfc33 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 10 Jan 2022 14:20:06 +0000 Subject: [PATCH] prosodyclient: Add support for exporting a user's account data --- snikket_web/prosodyclient.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/snikket_web/prosodyclient.py b/snikket_web/prosodyclient.py index ab6346f..c9a98ec 100644 --- a/snikket_web/prosodyclient.py +++ b/snikket_web/prosodyclient.py @@ -296,6 +296,9 @@ class ProsodyClient: def _public_v1_endpoint(self, subpath: str) -> str: return "{}/register_api{}".format(self._endpoint_base, subpath) + def _xep227_endpoint(self, subpath: str) -> str: + return "{}/xep227{}".format(self._endpoint_base, subpath) + async def _oauth2_bearer_token(self, session: aiohttp.ClientSession, jid: str, @@ -1121,6 +1124,18 @@ class ProsodyClient: ) as resp: self._raise_error_from_response(resp) + @autosession + async def export_account_data( + self, + *, + session: aiohttp.ClientSession, + ) -> str: + async with session.get( + self._xep227_endpoint("/export?stores=roster,vcard,pep"), + ) as resp: + self._raise_error_from_response(resp) + return await resp.text() + @autosession async def revoke_token( self,