mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 10:30:49 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -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`),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
36
src/upgrades/4.9.2/clean_tid_recipients_zsets.js
Normal file
36
src/upgrades/4.9.2/clean_tid_recipients_zsets.js
Normal 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,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user