From ce4b5679a23919271b5a27a29d048504cc85b3c8 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 9 Feb 2024 11:24:03 -0500 Subject: [PATCH] fix: only log warning on ap.send failure --- src/activitypub/index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/activitypub/index.js b/src/activitypub/index.js index f38b06cefb..0fd721a34d 100644 --- a/src/activitypub/index.js +++ b/src/activitypub/index.js @@ -223,18 +223,22 @@ ActivityPub.send = async (type, id, targets, payload) => { const keyData = await ActivityPub.getPrivateKey(type, id); const headers = await ActivityPub.sign(keyData, uri, payload); winston.verbose(`[activitypub/send] ${uri}`); - const { response, body } = await request.post(uri, { - headers: { - ...headers, - 'content-type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - }, - body: payload, - }); + try { + const { response, body } = await request.post(uri, { + headers: { + ...headers, + 'content-type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', + }, + body: payload, + }); - if (String(response.statusCode).startsWith('2')) { - winston.verbose(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`); - } else { - winston.warn(`[activitypub/send] Could not send ${payload.type} to ${uri}; error: ${body}`); + if (String(response.statusCode).startsWith('2')) { + winston.verbose(`[activitypub/send] Successfully sent ${payload.type} to ${uri}`); + } else { + winston.warn(`[activitypub/send] Could not send ${payload.type} to ${uri}; error: ${body}`); + } + } catch (e) { + winston.warn(`[activitypub/send] Could not send ${payload.type} to ${uri}; error: ${e.message}`); } })); };