feat: feature flag for auto-resolving a user's flags on ban [breaking]

The default behaviour has now been changed to 'off'. Going forward, a user's flags will no longer automatically resolve on ban.
This commit is contained in:
Julian Lam
2021-01-25 11:07:16 -05:00
parent a396b1099c
commit 6b1c97db79
3 changed files with 25 additions and 12 deletions

View File

@@ -628,18 +628,20 @@ Flags.resolveFlag = async function (type, id, uid) {
};
Flags.resolveUserPostFlags = async function (uid, callerUid) {
await batch.processSortedSet('uid:' + uid + ':posts', async function (pids) {
let postData = await posts.getPostsFields(pids, ['pid', 'flagId']);
postData = postData.filter(p => p && p.flagId);
for (const postObj of postData) {
if (parseInt(postObj.flagId, 10)) {
// eslint-disable-next-line no-await-in-loop
await Flags.update(postObj.flagId, callerUid, { state: 'resolved' });
if (meta.config['flags:autoResolveOnBan']) {
await batch.processSortedSet('uid:' + uid + ':posts', async function (pids) {
let postData = await posts.getPostsFields(pids, ['pid', 'flagId']);
postData = postData.filter(p => p && p.flagId);
for (const postObj of postData) {
if (parseInt(postObj.flagId, 10)) {
// eslint-disable-next-line no-await-in-loop
await Flags.update(postObj.flagId, callerUid, { state: 'resolved' });
}
}
}
}, {
batch: 500,
});
}, {
batch: 500,
});
}
};
Flags.getHistory = async function (flagId) {