From 510b6fb62c4600726bbcc5e08018e6897bc614ae Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 1 Dec 2023 18:22:26 +0100 Subject: [PATCH] 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. --- .../plugins/plugin_comp_ap_gateway/__init__.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py b/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py index 2648938c..8670aa83 100644 --- a/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py +++ b/libervia/backend/plugins/plugin_comp_ap_gateway/__init__.py @@ -2277,7 +2277,14 @@ class APGateway: 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 + return mess_data inbox = await self.get_ap_inbox_from_id(actor_id, use_shared=False) try: @@ -2313,7 +2320,13 @@ class APGateway: "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 + log.warning( + f"Can't send message to {inbox}: {e}" + ) return mess_data async def _on_message_retract(