This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

28
utils/postModeration.js Normal file
View 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,
}