fix: #13900, assertion re-index

This commit is contained in:
Julian Lam
2026-01-19 14:50:57 -05:00
parent 39582cbd02
commit 6383bb58e9

View File

@@ -275,7 +275,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
}, new Set())); }, new Set()));
const isBanned = await user.bans.isBanned(uids); const isBanned = await user.bans.isBanned(uids);
const banned = uids.filter((_, idx) => isBanned[idx]); const banned = uids.filter((_, idx) => isBanned[idx]);
unprocessed = unprocessed.filter(post => banned.includes(post.uid)); unprocessed = unprocessed.filter(post => !banned.includes(post.uid));
let added = []; let added = [];
await Promise.all(unprocessed.map(async (post) => { await Promise.all(unprocessed.map(async (post) => {
@@ -292,13 +292,11 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
if (added.length) { if (added.length) {
// Because replies are added in parallel, `index` is calculated incorrectly // Because replies are added in parallel, `index` is calculated incorrectly
added = added const indices = await posts.getPostIndices(added, uid);
.sort((a, b) => a.timestamp - b.timestamp) added = added.map((post, idx) => {
.map((post, idx) => { post.index = indices[idx];
post.index = post.index - idx; return post;
return post; });
})
.reverse();
websockets.in(`topic_${tid}`).emit('event:new_post', { posts: added }); websockets.in(`topic_${tid}`).emit('event:new_post', { posts: added });
} }
@@ -627,7 +625,6 @@ Notes.backfill = async (pids) => {
return Promise.all(pids.map(async (pid) => { return Promise.all(pids.map(async (pid) => {
if (backfillCache.has(pid)) { if (backfillCache.has(pid)) {
console.log('cache hit, not proactively backfilling');
return; return;
} }