mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
new reputation limit to post links if post queue is enabled and user doesn't have enough reputation to post links, queue their posts if post queue is NOT enabled and user doesn't have enough reputation to post links show error check content on topic post, topic reply, post edit
This commit is contained in:
committed by
GitHub
parent
c989a4a328
commit
979f24b173
@@ -85,6 +85,24 @@ module.exports = function (Posts) {
|
||||
postData.data.content = result.postData.content;
|
||||
}
|
||||
|
||||
Posts.canUserPostContentWithLinks = async function (uid, content) {
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
const [reputation, isPrivileged] = await Promise.all([
|
||||
user.getUserField(uid, 'reputation'),
|
||||
user.isPrivileged(uid),
|
||||
]);
|
||||
|
||||
if (!isPrivileged && reputation < meta.config['min:rep:post-links']) {
|
||||
const parsed = await plugins.hooks.fire('filter:parse.raw', String(content));
|
||||
if (parsed.match(/<a[^>]*>([^<]+)<\/a>/g)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Posts.shouldQueue = async function (uid, data) {
|
||||
const [userData, isMemberOfExempt, categoryQueueEnabled] = await Promise.all([
|
||||
user.getUserFields(uid, ['uid', 'reputation', 'postcount']),
|
||||
@@ -94,7 +112,12 @@ module.exports = function (Posts) {
|
||||
|
||||
const shouldQueue = meta.config.postQueue && categoryQueueEnabled &&
|
||||
!isMemberOfExempt &&
|
||||
(!userData.uid || userData.reputation < meta.config.postQueueReputationThreshold || userData.postcount <= 0);
|
||||
(
|
||||
!userData.uid ||
|
||||
userData.reputation < meta.config.postQueueReputationThreshold ||
|
||||
userData.postcount <= 0 ||
|
||||
!await Posts.canUserPostContentWithLinks(uid, data.content)
|
||||
);
|
||||
const result = await plugins.hooks.fire('filter:post.shouldQueue', {
|
||||
shouldQueue: !!shouldQueue,
|
||||
uid: uid,
|
||||
|
||||
Reference in New Issue
Block a user