From 7207814b9087579f8ed3e8fd3a66f054bac94716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 27 Feb 2024 09:20:44 -0500 Subject: [PATCH] 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 --- src/user/posts.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/user/posts.js b/src/user/posts.js index 5ee7f5e8aa..318718f1c0 100644 --- a/src/user/posts.js +++ b/src/user/posts.js @@ -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}]]`);