mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 00:07:25 +02:00
feat: check room counts on actor prune, #12834
This commit is contained in:
@@ -278,7 +278,6 @@ Actors.remove = async (id) => {
|
|||||||
Actors.prune = async () => {
|
Actors.prune = async () => {
|
||||||
/**
|
/**
|
||||||
* Clear out remote user accounts that do not have content on the forum anywhere
|
* Clear out remote user accounts that do not have content on the forum anywhere
|
||||||
* Re-crawl those that have not been updated recently
|
|
||||||
*/
|
*/
|
||||||
winston.info('[actors/prune] Started scheduled pruning of remote user accounts');
|
winston.info('[actors/prune] Started scheduled pruning of remote user accounts');
|
||||||
|
|
||||||
@@ -295,7 +294,10 @@ Actors.prune = async () => {
|
|||||||
|
|
||||||
await batch.processArray(uids, async (uids) => {
|
await batch.processArray(uids, async (uids) => {
|
||||||
const exists = await db.exists(uids.map(uid => `userRemote:${uid}`));
|
const exists = await db.exists(uids.map(uid => `userRemote:${uid}`));
|
||||||
const postCounts = await db.sortedSetsCard(uids.map(uid => `uid:${uid}:posts`));
|
const [postCounts, roomCounts] = await Promise.all([
|
||||||
|
db.sortedSetsCard(uids.map(uid => `uid:${uid}:posts`)),
|
||||||
|
db.sortedSetsCard(uids.map(uid => `uid:${uid}:chat:rooms`)),
|
||||||
|
]);
|
||||||
await Promise.all(uids.map(async (uid, idx) => {
|
await Promise.all(uids.map(async (uid, idx) => {
|
||||||
if (!exists[idx]) {
|
if (!exists[idx]) {
|
||||||
// id in zset but not asserted, handle and return early
|
// id in zset but not asserted, handle and return early
|
||||||
@@ -305,7 +307,8 @@ Actors.prune = async () => {
|
|||||||
|
|
||||||
const { followers, following } = await Actors.getLocalFollowCounts(uid);
|
const { followers, following } = await Actors.getLocalFollowCounts(uid);
|
||||||
const postCount = postCounts[idx];
|
const postCount = postCounts[idx];
|
||||||
if ([postCount, followers, following].every(metric => metric < 1)) {
|
const roomCount = roomCounts[idx];
|
||||||
|
if ([postCount, roomCount, followers, following].every(metric => metric < 1)) {
|
||||||
try {
|
try {
|
||||||
await user.deleteAccount(uid);
|
await user.deleteAccount(uid);
|
||||||
deletionCount += 1;
|
deletionCount += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user