mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
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:
@@ -16,5 +16,7 @@
|
||||
|
||||
"flags": "Flag Settings",
|
||||
"flags.limit-per-target": "Maximum number of times something can be flagged",
|
||||
"flags.limit-per-target-placeholder": "Default: 0"
|
||||
"flags.limit-per-target-placeholder": "Default: 0",
|
||||
"flags.limit-per-target-help": "When a post or user is flagged multiple times, each additional flag is considered a "report" and added to the original flag. Set this option to a number other than zero to limit the number of reports an item can receive.",
|
||||
"flags.auto-resolve-on-ban": "Automatically resolve all of a user's tickets when they are banned"
|
||||
}
|
||||
24
src/flags.js
24
src/flags.js
@@ -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) {
|
||||
|
||||
@@ -78,6 +78,15 @@
|
||||
<div class="form-group">
|
||||
<label for="flags:limitPerTarget">[[admin/settings/reputation:flags.limit-per-target]]</label>
|
||||
<input type="text" class="form-control" placeholder="[[admin/settings/reputation:flags.limit-per-target-placeholder]]" data-field="flags:limitPerTarget" id="flags:limitPerTarget">
|
||||
<p class="help-block">
|
||||
[[admin/settings/reputation:flags.limit-per-target-help]]
|
||||
</p>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input type="checkbox" class="mdl-switch__input" data-field="flags:autoResolveOnBan">
|
||||
<span class="mdl-switch__label"><strong>[[admin/settings/reputation:flags.auto-resolve-on-ban]]</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user