diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js index 770ae1a4ca..950d8bb2ec 100644 --- a/src/activitypub/inbox.js +++ b/src/activitypub/inbox.js @@ -25,7 +25,7 @@ inbox.create = async (req) => { throw new Error('[[error:activitypub.not-implemented]]'); } - const { tid, count } = await activitypub.notes.assert(0, object.id); + const { tid, count } = await activitypub.notes.assert(0, object); winston.verbose(`[activitypub/inbox] Parsing ${count} notes into topic ${tid}`); }; @@ -129,7 +129,7 @@ inbox.announce = async (req) => { return; } - ({ tid } = await activitypub.notes.assert(0, pid, object)); + ({ tid } = await activitypub.notes.assert(0, pid)); if (!tid) { return; } diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 9c6b061eb5..f8330849df 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -16,15 +16,16 @@ const utils = require('../utils'); const activitypub = module.parent.exports; const Notes = module.exports; -Notes.assert = async (uid, id, object) => { +Notes.assert = async (uid, input) => { /** - * Given the id (or optional AS object) of any post, traverses up to cache the entire threaded context + * Given the id or object of any as:Note, traverses up to cache the entire threaded context * * Unfortunately, due to limitations and fragmentation of the existing ActivityPub landscape, * retrieving the entire reply tree is not possible at this time. */ - const chain = Array.from(await Notes.getParentChain(uid, object || id)); + const object = !activitypub.helpers.isUri(input) && input; + const chain = Array.from(await Notes.getParentChain(uid, input)); if (!chain.length) { return null; } @@ -127,7 +128,7 @@ Notes.assert = async (uid, id, object) => { ]); // Category announce - if (id === post.pid) { + if (object && object.id === post.pid) { // eslint-disable-next-line no-await-in-loop const followers = await activitypub.notes.getCategoryFollowers(cid); // eslint-disable-next-line no-await-in-loop