@ -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 fals e;
return tru e;
}
}
const [ reputation , isPrivileged ] = await Promise . all ( [
const [ reputation , isPrivileged ] = await Promise . all ( [
user . getUserField ( uid , 'reputation' ) ,
user . getUserField ( uid , 'reputation' ) ,
@ -104,13 +104,16 @@ 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 ;
if ( shouldQueue ) {
const [ userData , isPrivileged , isMemberOfExempt , categoryQueueEnabled ] = await Promise . all ( [
user . getUserFields ( uid , [ 'uid' , 'reputation' , 'postcount' ] ) ,
user . getUserFields ( uid , [ 'uid' , 'reputation' , 'postcount' ] ) ,
user . isPrivileged ( uid ) ,
groups . isMemberOfAny ( uid , meta . config . groupsExemptFromPostQueue ) ,
groups . isMemberOfAny ( uid , meta . config . groupsExemptFromPostQueue ) ,
isCategoryQueueEnabled ( data ) ,
isCategoryQueueEnabled ( data ) ,
] ) ;
] ) ;
shouldQueue = categoryQueueEnabled &&
const shouldQueue = meta . config . postQueue && categoryQueueEnabl ed &&
! isPrivileg ed &&
! isMemberOfExempt &&
! isMemberOfExempt &&
(
(
! userData . uid ||
! userData . uid ||
@ -118,6 +121,8 @@ module.exports = function (Posts) {
userData . postcount <= 0 ||
userData . postcount <= 0 ||
! await Posts . canUserPostContentWithLinks ( uid , data . content )
! 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' ) ;
}
}