Skip to content

Node.js based forum software built for the modern web

fix: #11766, allow privileged users to vote and chat

Barış Soner Uşaklı1bda90731aed
diff --git a/src/messaging/index.js b/src/messaging/index.js
index 729ec8fedf..e532043a12 100644
--- a/src/messaging/index.js
+++ b/src/messaging/index.js
@@ -292,8 +292,11 @@ async function checkReputation(uid) {
if (meta.config['reputation:disabled']) {
return;
}
- const reputation = await user.getUserField(uid, 'reputation');
- if (meta.config['min:rep:chat'] > reputation) {
+ const [reputation, isPrivileged] = await Promise.all([
+ user.getUserField(uid, 'reputation'),
+ user.isPrivileged(uid),
+ ]);
+ if (!isPrivileged && meta.config['min:rep:chat'] > reputation) {
throw new Error(`[[error:not-enough-reputation-to-chat, ${meta.config['min:rep:chat']}]]`);
}
}
diff --git a/src/posts/votes.js b/src/posts/votes.js
index dfdfad2899..bfe5e1e47f 100644
--- a/src/posts/votes.js
+++ b/src/posts/votes.js
@@ -142,14 +142,17 @@ module.exports = function (Posts) {
async function checkVoteLimitation(pid, uid, type) {
// type = 'upvote' or 'downvote'
const oneDay = 86400000;
- const [reputation, targetUid, votedPidsToday] = await Promise.all([
+ const [reputation, isPrivileged, targetUid, votedPidsToday] = await Promise.all([
user.getUserField(uid, 'reputation'),
+ user.isPrivileged(uid),
Posts.getPostField(pid, 'uid'),
db.getSortedSetRevRangeByScore(
`uid:${uid}:${type}`, 0, -1, '+inf', Date.now() - oneDay
),
]);
-
+ if (isPrivileged) {
+ return;
+ }
if (reputation < meta.config[`min:rep:${type}`]) {
throw new Error(`[[error:not-enough-reputation-to-${type}, ${meta.config[`min:rep:${type}`]}]]`);
}