mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
feat: #11949, show alert if posts is going to be queued
This commit is contained in:
@@ -90,6 +90,7 @@
|
|||||||
"composer.zen_mode": "Zen Mode",
|
"composer.zen_mode": "Zen Mode",
|
||||||
"composer.select_category": "Select a category",
|
"composer.select_category": "Select a category",
|
||||||
"composer.textarea.placeholder": "Enter your post content here, drag and drop images",
|
"composer.textarea.placeholder": "Enter your post content here, drag and drop images",
|
||||||
|
"composer.post-queue-alert": "Hello👋!<br/>This forum uses a post queue system, since you are a new user your post will be hidden until it is approved by our moderation team.",
|
||||||
"composer.schedule-for": "Schedule topic for",
|
"composer.schedule-for": "Schedule topic for",
|
||||||
"composer.schedule-date": "Date",
|
"composer.schedule-date": "Date",
|
||||||
"composer.schedule-time": "Time",
|
"composer.schedule-time": "Time",
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ get:
|
|||||||
type: boolean
|
type: boolean
|
||||||
maintenanceMode:
|
maintenanceMode:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
postQueue:
|
||||||
|
type: number
|
||||||
minimumTitleLength:
|
minimumTitleLength:
|
||||||
type: number
|
type: number
|
||||||
maximumTitleLength:
|
maximumTitleLength:
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ apiController.loadConfig = async function (req) {
|
|||||||
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),
|
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),
|
||||||
showSiteTitle: meta.config.showSiteTitle === 1,
|
showSiteTitle: meta.config.showSiteTitle === 1,
|
||||||
maintenanceMode: meta.config.maintenanceMode === 1,
|
maintenanceMode: meta.config.maintenanceMode === 1,
|
||||||
|
postQueue: meta.config.postQueue,
|
||||||
minimumTitleLength: meta.config.minimumTitleLength,
|
minimumTitleLength: meta.config.minimumTitleLength,
|
||||||
maximumTitleLength: meta.config.maximumTitleLength,
|
maximumTitleLength: meta.config.maximumTitleLength,
|
||||||
minimumPostLength: meta.config.minimumPostLength,
|
minimumPostLength: meta.config.minimumPostLength,
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ module.exports = function (Posts) {
|
|||||||
|
|
||||||
Posts.canUserPostContentWithLinks = async function (uid, content) {
|
Posts.canUserPostContentWithLinks = async function (uid, content) {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
const [reputation, isPrivileged] = await Promise.all([
|
const [reputation, isPrivileged] = await Promise.all([
|
||||||
user.getUserField(uid, 'reputation'),
|
user.getUserField(uid, 'reputation'),
|
||||||
@@ -104,20 +104,25 @@ module.exports = function (Posts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Posts.shouldQueue = async function (uid, data) {
|
Posts.shouldQueue = async function (uid, data) {
|
||||||
const [userData, isMemberOfExempt, categoryQueueEnabled] = await Promise.all([
|
let shouldQueue = meta.config.postQueue;
|
||||||
user.getUserFields(uid, ['uid', 'reputation', 'postcount']),
|
if (shouldQueue) {
|
||||||
groups.isMemberOfAny(uid, meta.config.groupsExemptFromPostQueue),
|
const [userData, isPrivileged, isMemberOfExempt, categoryQueueEnabled] = await Promise.all([
|
||||||
isCategoryQueueEnabled(data),
|
user.getUserFields(uid, ['uid', 'reputation', 'postcount']),
|
||||||
]);
|
user.isPrivileged(uid),
|
||||||
|
groups.isMemberOfAny(uid, meta.config.groupsExemptFromPostQueue),
|
||||||
|
isCategoryQueueEnabled(data),
|
||||||
|
]);
|
||||||
|
shouldQueue = categoryQueueEnabled &&
|
||||||
|
!isPrivileged &&
|
||||||
|
!isMemberOfExempt &&
|
||||||
|
(
|
||||||
|
!userData.uid ||
|
||||||
|
userData.reputation < meta.config.postQueueReputationThreshold ||
|
||||||
|
userData.postcount <= 0 ||
|
||||||
|
!await Posts.canUserPostContentWithLinks(uid, data.content)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const shouldQueue = meta.config.postQueue && categoryQueueEnabled &&
|
|
||||||
!isMemberOfExempt &&
|
|
||||||
(
|
|
||||||
!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', {
|
const result = await plugins.hooks.fire('filter:post.shouldQueue', {
|
||||||
shouldQueue: !!shouldQueue,
|
shouldQueue: !!shouldQueue,
|
||||||
uid: uid,
|
uid: uid,
|
||||||
@@ -130,7 +135,7 @@ module.exports = function (Posts) {
|
|||||||
const type = getType(data);
|
const type = getType(data);
|
||||||
const cid = await getCid(type, data);
|
const cid = await getCid(type, data);
|
||||||
if (!cid) {
|
if (!cid) {
|
||||||
throw new Error('[[error:invalid-cid]]');
|
return true;
|
||||||
}
|
}
|
||||||
return await categories.getCategoryField(cid, 'postQueue');
|
return await categories.getCategoryField(cid, 'postQueue');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user