Skip to content

Node.js based forum software built for the modern web

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

Julian Lam6b1c97db797d
diff --git a/public/language/en-GB/admin/settings/reputation.json b/public/language/en-GB/admin/settings/reputation.json
index f5659569a9..7cfa636521 100644
--- a/public/language/en-GB/admin/settings/reputation.json
+++ b/public/language/en-GB/admin/settings/reputation.json
@@ -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"
}
\ No newline at end of file
diff --git a/src/flags.js b/src/flags.js
index c6a2a90edd..444384c379 100644
--- a/src/flags.js
+++ b/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) {
diff --git a/src/views/admin/settings/reputation.tpl b/src/views/admin/settings/reputation.tpl
index 1ce7d808dd..c6e5c62387 100644
--- a/src/views/admin/settings/reputation.tpl
+++ b/src/views/admin/settings/reputation.tpl
@@ -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>