full
This commit is contained in:
28
utils/postModeration.js
Normal file
28
utils/postModeration.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { isPublicPostStatus } = require('./moderationStatus')
|
||||
|
||||
function applyReportHiddenFilter (filter = {}) {
|
||||
const hiddenGuard = {
|
||||
$or: [
|
||||
{ report_hidden: false },
|
||||
{ report_hidden: { $exists: false } },
|
||||
{ report_hidden: null },
|
||||
],
|
||||
}
|
||||
|
||||
if (filter.$and) {
|
||||
return { ...filter, $and: [...filter.$and, hiddenGuard] }
|
||||
}
|
||||
|
||||
return { ...filter, $and: [hiddenGuard] }
|
||||
}
|
||||
|
||||
function isPostPubliclyVisible (post) {
|
||||
if (!post) return false
|
||||
if (!isPublicPostStatus(post.status)) return false
|
||||
return post.report_hidden !== true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
applyReportHiddenFilter,
|
||||
isPostPubliclyVisible,
|
||||
}
|
||||
Reference in New Issue
Block a user