Node.js based forum software built for the modern web
fix: don't crash on activitypub.send non-2xx, better logging for successful sends
Julian Lamac56289fa261
diff --git a/src/activitypub/index.js b/src/activitypub/index.jsindex 0c7fb0b777..f38b06cefb 100644--- a/src/activitypub/index.js+++ b/src/activitypub/index.js@@ -223,7 +223,7 @@ 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 } = await request.post(uri, {+ const { response, body } = await request.post(uri, {headers: {...headers,'content-type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',@@ -231,9 +231,10 @@ ActivityPub.send = async (type, id, targets, payload) => {body: payload,});- if (!String(response.statusCode).startsWith('2')) {- // todo: i18n this- throw new Error('activity-failed');+ 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}`);}}));};