Skip to content

Node.js based forum software built for the modern web

feat: return count of new notes in assertTopic

Julian Lam519e025e271f
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index c629926d34..25c940fa34 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -26,8 +26,8 @@ inbox.create = async (req) => {
throw new Error('[[error:activitypub.not-implemented]]');
}
- const tid = await activitypub.notes.assertTopic(0, object.id);
- winston.verbose(`[activitypub/inbox] Parsing note ${object.id} into topic ${tid}`);
+ const { tid, count } = await activitypub.notes.assertTopic(0, object.id);
+ winston.verbose(`[activitypub/inbox] Parsing ${count} notes into topic ${tid}`);
};
inbox.update = async (req) => {
@@ -125,7 +125,7 @@ inbox.announce = async (req) => {
return;
}
- tid = await activitypub.notes.assertTopic(0, pid);
+ ({ tid } = await activitypub.notes.assertTopic(0, pid));
if (!tid) {
return;
}
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 5bd414edae..ec74514844 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -245,7 +245,8 @@ Notes.assertTopic = async (uid, id) => {
post.tid = tid; // add tid to post hash
return post;
}).filter((p, idx) => !members[idx]);
- winston.verbose(`[notes/assertTopic] ${unprocessed.length} new note(s) found.`);
+ const count = unprocessed.length;
+ winston.verbose(`[notes/assertTopic] ${count} new note(s) found.`);
const [ids, timestamps] = [
unprocessed.map(n => (utils.isNumber(n.pid) ? parseInt(n.pid, 10) : n.pid)),
@@ -287,7 +288,7 @@ Notes.assertTopic = async (uid, id) => {
await Notes.syncUserInboxes(tid);
- return tid;
+ return { tid, count };
};
Notes.syncUserInboxes = async function (tid) {