Mercurial > libervia-backend
changeset 4169:e92c32014024
component AP gateway: log a warning instead of raising an exception in `onMessage`:
if something goes wrong, a warning is logged instead of raising a failing in `onMessage`'s
`get_ap_actor_id_from_account` and `sign_and_post` calls.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Dec 2023 18:22:26 +0100 |
parents | d67eaa684484 |
children | b47f21f2b8fa |
files | libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py Fri Dec 01 18:20:27 2023 +0100 +++ b/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py Fri Dec 01 18:22:26 2023 +0100 @@ -2277,7 +2277,14 @@ return mess_data actor_account = self._e.unescape(mess_data["to"].user) - actor_id = await self.get_ap_actor_id_from_account(actor_account) + try: + actor_id = await self.get_ap_actor_id_from_account(actor_account) + except Exception as e: + log.warning( + f"Can't retrieve data on actor {actor_account}: {e}" + ) + # TODO: send an error <message> + return mess_data inbox = await self.get_ap_inbox_from_id(actor_id, use_shared=False) try: @@ -2313,7 +2320,13 @@ "name": f"@{actor_account}", }) - await self.sign_and_post(inbox, ap_item["actor"], ap_item) + try: + await self.sign_and_post(inbox, ap_item["actor"], ap_item) + except Exception as e: + # TODO: send an error <message> + log.warning( + f"Can't send message to {inbox}: {e}" + ) return mess_data async def _on_message_retract(