mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: use isPrivileged instead of isAdmin
This commit is contained in:
committed by
Julian Lam
parent
ff07fc44e2
commit
b9c3cdb679
@@ -17,16 +17,18 @@ const chatsAPI = module.exports;
|
||||
async function rateLimitExceeded(caller) {
|
||||
const session = caller.request ? caller.request.session : caller.session; // socket vs req
|
||||
const now = Date.now();
|
||||
const [isAdmin, reputation] = await Promise.all([
|
||||
user.isAdministrator(caller.uid),
|
||||
const [isPrivileged, reputation] = await Promise.all([
|
||||
user.isPrivileged(caller.uid),
|
||||
user.getUserField(caller.uid, 'reputation'),
|
||||
]);
|
||||
const newbie = !isAdmin && meta.config.newbiePostDelayThreshold > reputation;
|
||||
const newbie = !isPrivileged && meta.config.newbiePostDelayThreshold > reputation;
|
||||
const delay = newbie ? meta.config.newbieChatMessageDelay : meta.config.chatMessageDelay;
|
||||
session.lastChatMessageTime = session.lastChatMessageTime || 0;
|
||||
|
||||
if (now - session.lastChatMessageTime < delay) {
|
||||
return true;
|
||||
}
|
||||
|
||||
session.lastChatMessageTime = now;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user