diff --git a/snikket_web/prosodyclient.py b/snikket_web/prosodyclient.py index c9a98ec..6b530f1 100644 --- a/snikket_web/prosodyclient.py +++ b/snikket_web/prosodyclient.py @@ -1129,11 +1129,13 @@ class ProsodyClient: self, *, session: aiohttp.ClientSession, - ) -> str: + ) -> typing.Optional[str]: async with session.get( self._xep227_endpoint("/export?stores=roster,vcard,pep"), ) as resp: self._raise_error_from_response(resp) + if resp.status == 204: + return None return await resp.text() @autosession diff --git a/snikket_web/user.py b/snikket_web/user.py index 978ae4b..eb9e278 100644 --- a/snikket_web/user.py +++ b/snikket_web/user.py @@ -1,4 +1,3 @@ -import aiohttp import asyncio import typing import urllib @@ -188,16 +187,12 @@ async def manage_data() -> typing.Union[str, quart.Response]: encoded_address = urllib.parse.quote( user_info["address"].encode(encoding='utf-8', errors='strict') ) - try: - account_data = await client.export_account_data() - except aiohttp.ClientResponseError as e: - if e.status == 404: - await flash( - _("You currently have no account data to export."), - "alert" - ) - else: - raise e + account_data = await client.export_account_data() + if account_data is None: + await flash( + _("You currently have no account data to export."), + "alert" + ) else: return Response(account_data, mimetype="application/xml",