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.
v1.18.x
Julian Lam 4 years ago
parent a396b1099c
commit 6b1c97db79

@ -16,5 +16,7 @@
"flags": "Flag Settings", "flags": "Flag Settings",
"flags.limit-per-target": "Maximum number of times something can be flagged", "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"
} }

@ -628,6 +628,7 @@ Flags.resolveFlag = async function (type, id, uid) {
}; };
Flags.resolveUserPostFlags = async function (uid, callerUid) { Flags.resolveUserPostFlags = async function (uid, callerUid) {
if (meta.config['flags:autoResolveOnBan']) {
await batch.processSortedSet('uid:' + uid + ':posts', async function (pids) { await batch.processSortedSet('uid:' + uid + ':posts', async function (pids) {
let postData = await posts.getPostsFields(pids, ['pid', 'flagId']); let postData = await posts.getPostsFields(pids, ['pid', 'flagId']);
postData = postData.filter(p => p && p.flagId); postData = postData.filter(p => p && p.flagId);
@ -640,6 +641,7 @@ Flags.resolveUserPostFlags = async function (uid, callerUid) {
}, { }, {
batch: 500, batch: 500,
}); });
}
}; };
Flags.getHistory = async function (flagId) { Flags.getHistory = async function (flagId) {

@ -78,6 +78,15 @@
<div class="form-group"> <div class="form-group">
<label for="flags:limitPerTarget">[[admin/settings/reputation:flags.limit-per-target]]</label> <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"> <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> </div>
</form> </form>
</div> </div>

Loading…
Cancel
Save