mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add hook into user.posts.isReady
can be used to disable post delays or apply custom logic closes https://github.com/NodeBB/NodeBB/pull/12367
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const db = require('../database');
|
||||
const meta = require('../meta');
|
||||
const privileges = require('../privileges');
|
||||
const plugins = require('../plugins');
|
||||
const groups = require('../groups');
|
||||
|
||||
module.exports = function (User) {
|
||||
@@ -48,6 +49,18 @@ module.exports = function (User) {
|
||||
|
||||
await User.checkMuted(uid);
|
||||
|
||||
const { shouldIgnoreDelays } = await plugins.hooks.fire('filter:user.posts.isReady', {
|
||||
shouldIgnoreDelays: false,
|
||||
user: userData,
|
||||
cid,
|
||||
field,
|
||||
isAdminOrMod,
|
||||
isMemberOfExempt,
|
||||
});
|
||||
if (shouldIgnoreDelays) {
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
if (now - userData.joindate < meta.config.initialPostDelay * 1000) {
|
||||
throw new Error(`[[error:user-too-new, ${meta.config.initialPostDelay}]]`);
|
||||
|
||||
Reference in New Issue
Block a user