Skip to content

Node.js based forum software built for the modern web

fix: move AP send logging earlier

Julian Lamdca3c35d7685
diff --git a/src/activitypub/index.js b/src/activitypub/index.js
index 49fa028eff..6415582e2a 100644
--- a/src/activitypub/index.js
+++ b/src/activitypub/index.js
@@ -337,11 +337,6 @@ async function sendMessage(uri, id, type, payload, attempts = 1) {
const keyData = await ActivityPub.getPrivateKey(type, id);
const headers = await ActivityPub.sign(keyData, uri, payload);
- ActivityPub.helpers.log(`[activitypub/send] ${uri}`);
- if (process.env.hasOwnProperty('CI')) {
- ActivityPub._sent.set(payload.id, payload);
- }
-
try {
const { response, body } = await request.post(uri, {
headers: {
@@ -381,6 +376,11 @@ ActivityPub.send = async (type, id, targets, payload) => {
return ActivityPub.helpers.log('[activitypub/send] Federation not enabled; not sending.');
}
+ ActivityPub.helpers.log(`[activitypub/send] ${payload.id}`);
+ if (process.env.hasOwnProperty('CI')) {
+ ActivityPub._sent.set(payload.id, payload);
+ }
+
if (!Array.isArray(targets)) {
targets = [targets];
}
diff --git a/test/activitypub.js b/test/activitypub.js
index 4993ef6111..4a619e1c8f 100644
--- a/test/activitypub.js
+++ b/test/activitypub.js
@@ -35,7 +35,7 @@ describe('ActivityPub integration', () => {
const uid = await user.create({ username: uuid });
await activitypub.send('uid', 0, [`https://localhost/uid/${uid}`], { id: `${nconf.get('url')}/activity/${uuid}`, foo: 'bar' });
- assert(activitypub._sent.has(`https://localhost/activity/${uuid}`));
+ assert(activitypub._sent.has(`${nconf.get('url')}/activity/${uuid}`));
});
});
diff --git a/test/activitypub/feps.js b/test/activitypub/feps.js
index e8a826e4e2..59ef838fa9 100644
--- a/test/activitypub/feps.js
+++ b/test/activitypub/feps.js
@@ -59,9 +59,7 @@ describe('FEPs', () => {
cid,
});
- setTimeout(() => {
- assert.strictEqual(activitypub._sent.size, 1);
- }, 250);
+ assert.strictEqual(activitypub._sent.size, 1);
});
});
});