feat: return count of new notes in assertTopic

This commit is contained in:
Julian Lam
2024-03-13 11:03:08 -04:00
parent 338c568c99
commit 519e025e27
2 changed files with 6 additions and 5 deletions

View File

@@ -26,8 +26,8 @@ inbox.create = async (req) => {
throw new Error('[[error:activitypub.not-implemented]]'); throw new Error('[[error:activitypub.not-implemented]]');
} }
const tid = await activitypub.notes.assertTopic(0, object.id); const { tid, count } = await activitypub.notes.assertTopic(0, object.id);
winston.verbose(`[activitypub/inbox] Parsing note ${object.id} into topic ${tid}`); winston.verbose(`[activitypub/inbox] Parsing ${count} notes into topic ${tid}`);
}; };
inbox.update = async (req) => { inbox.update = async (req) => {
@@ -125,7 +125,7 @@ inbox.announce = async (req) => {
return; return;
} }
tid = await activitypub.notes.assertTopic(0, pid); ({ tid } = await activitypub.notes.assertTopic(0, pid));
if (!tid) { if (!tid) {
return; return;
} }

View File

@@ -245,7 +245,8 @@ Notes.assertTopic = async (uid, id) => {
post.tid = tid; // add tid to post hash post.tid = tid; // add tid to post hash
return post; return post;
}).filter((p, idx) => !members[idx]); }).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] = [ const [ids, timestamps] = [
unprocessed.map(n => (utils.isNumber(n.pid) ? parseInt(n.pid, 10) : n.pid)), 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); await Notes.syncUserInboxes(tid);
return tid; return { tid, count };
}; };
Notes.syncUserInboxes = async function (tid) { Notes.syncUserInboxes = async function (tid) {