Merge branch 'master' into develop

This commit is contained in:
Barış Soner Uşaklı
2026-03-05 13:45:34 -05:00
2 changed files with 53 additions and 2 deletions

View File

@@ -96,8 +96,10 @@ module.exports = function (Topics) {
t.tags = t.tags.map(tag => tag.value);
});
await deleteFromFollowersIgnorers(tidsToDelete);
await Promise.all([
deleteFromFollowersIgnorers(tidsToDelete),
deleteFromUserInboxes(tidsToDelete),
]);
const remoteTids = [];
const localTids = [];
@@ -163,6 +165,18 @@ module.exports = function (Topics) {
await db.sortedSetRemoveBulk(bulkRemove);
}
async function deleteFromUserInboxes(tids) {
const recipients = await db.getSortedSetsMembers(tids.map(tid => `tid:${tid}:recipients`));
const bulkRemove = [];
tids.forEach((tid, index) => {
const tidRecipients = recipients[index];
tidRecipients.forEach((uid) => {
bulkRemove.push([`uid:${uid}:inbox`, tid]);
});
});
await db.sortedSetRemoveBulk(bulkRemove);
}
async function deleteKeys(tids) {
await db.deleteAll([
...tids.map(tid => `tid:${tid}:followers`),
@@ -171,6 +185,7 @@ module.exports = function (Topics) {
...tids.map(tid => `tid:${tid}:posts:votes`),
...tids.map(tid => `tid:${tid}:bookmarks`),
...tids.map(tid => `tid:${tid}:posters`),
...tids.map(tid => `tid:${tid}:recipients`),
]);
}

View File

@@ -0,0 +1,36 @@
'use strict';
const db = require('../../database');
const batch = require('../../batch');
module.exports = {
name: 'Delete pruned tids from user inboxes and delete tid:<tid>:recipients sorted sets',
timestamp: Date.UTC(2026, 2, 5),
method: async function () {
const { progress } = this;
progress.total = await db.sortedSetCard('users:joindate');
await batch.processSortedSet('users:joindate', async (uids) => {
const userInboxes = await db.getSortedSetsMembers(uids.map(uid => `uid:${uid}:inbox`));
const exists = await Promise.all(
userInboxes.map(userTids => db.exists(userTids.map(tid => `topic:${tid}`)))
);
const bulkRemove = [];
const deleteTids = new Set();
uids.forEach((uid, index) => {
const userTids = userInboxes[index];
userTids.forEach((tid, tidIndex) => {
if (!exists[index][tidIndex]) {
bulkRemove.push([`uid:${uid}:inbox`, tid]);
deleteTids.add(tid);
}
});
});
await db.deleteAll(Array.from(deleteTids).map(tid => `tid:${tid}:recipients`));
progress.incr(uids.length);
}, {
batch: 500,
});
},
};