mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
feat: banning a user will resolve their post flags
This commit is contained in:
16
src/flags.js
16
src/flags.js
@@ -16,6 +16,7 @@ const posts = require('./posts');
|
||||
const privileges = require('./privileges');
|
||||
const plugins = require('./plugins');
|
||||
const utils = require('../public/src/utils');
|
||||
const batch = require('./batch');
|
||||
|
||||
const Flags = module.exports;
|
||||
|
||||
@@ -571,6 +572,21 @@ 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' });
|
||||
}
|
||||
}
|
||||
}, {
|
||||
batch: 500,
|
||||
});
|
||||
};
|
||||
|
||||
Flags.getHistory = async function (flagId) {
|
||||
const uids = [];
|
||||
let history = await db.getSortedSetRevRangeWithScores('flag:' + flagId + ':history', 0, -1);
|
||||
|
||||
Reference in New Issue
Block a user