diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js index 8aaa1ce279..de6c14f53f 100644 --- a/src/activitypub/inbox.js +++ b/src/activitypub/inbox.js @@ -98,6 +98,10 @@ inbox.announce = async (req) => { } else { pid = object; tid = await activitypub.notes.assertTopic(0, object); + if (!tid) { + return; + } + await topics.updateLastPostTime(tid, timestamp); } diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index 9ffb93e32e..a360198446 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -122,7 +122,6 @@ Notes.getParentChain = async (uid, input) => { } } catch (e) { winston.warn(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`); - chain.delete(id); } } }; @@ -153,6 +152,10 @@ Notes.assertTopic = async (uid, id) => { */ const chain = Array.from(await Notes.getParentChain(uid, id)); + if (!chain.length) { + return null; + } + let { pid: mainPid, tid, uid: authorId, timestamp, name, content } = chain[chain.length - 1]; const members = await db.isSortedSetMembers(`tid:${tid}:posts`, chain.map(p => p.pid)); if (tid && members.every(Boolean)) {