From 5ee1fd02bb2dca745f03ec27e982223b498662b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 26 Aug 2025 19:23:39 -0400 Subject: [PATCH] refactor: add missing awaits fix error message, lock not using second param --- src/activitypub/notes.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 7e1a50e7da..da683c51a7 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -56,15 +56,16 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { } const id = !activitypub.helpers.isUri(input) ? input.id : input; - const lockStatus = await lock(id, '[[error:activitypub.already-asserting]]'); + const lockStatus = await lock(id); if (!lockStatus) { // unable to achieve lock, stop processing. + winston.warn('[activitypub/notes.assert] Unable to acquire lock, skipping processing of', id); return null; } let chain; let context = await activitypub.contexts.get(uid, id); if (context.tid) { - unlock(id); + await unlock(id); const { tid } = context; return { tid, count: 0 }; } else if (context.context) { @@ -85,7 +86,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { // Can't resolve — give up. if (!chain.length) { - unlock(id); + await unlock(id); return null; } @@ -108,7 +109,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { if (tid && members.every(Boolean)) { // All cached, return early. activitypub.helpers.log('[notes/assert] No new notes to process.'); - unlock(id); + await unlock(id); return { tid, count: 0 }; } @@ -137,6 +138,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { }).shift(); } catch (e) { // noop + winston.error('[activitypub/notes.assert] Could not parse URL of mainPid', e.stack); } if (remoteCid || recipientCids.length) { @@ -169,6 +171,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { uid || hasTid || options.skipChecks || options.cid || await assertRelation(chain[inputIndex !== -1 ? inputIndex : 0]); + const privilege = `topics:${tid ? 'reply' : 'create'}`; const allowed = await privileges.categories.can(privilege, options.cid || cid, activitypub._constants.uid); if (!hasRelation || !allowed) { @@ -176,7 +179,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => { activitypub.helpers.log(`[activitypub/notes.assert] Not asserting ${id} as it has no relation to existing tracked content.`); } - unlock(id); + await unlock(id); return null; }