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

View File

@@ -0,0 +1,63 @@
/**
* Moderation helpers for comments and posts (Persian profanity + explicit cues).
*/
const PROFANITY_PATTERNS = [
/\b(کس|کیر|کون|جنده|حروم|لاشی|بی\s*شعور|گه|گایید|گائید)\b/i,
/\b(fuck|shit|bitch|asshole)\b/i,
];
const EXPLICIT_CONTENT_PATTERNS = [
/\b(برهنگ|برهنگی|پورن|porn|nude|naked|sex)\b/i,
/\b(سکس|جنسی\s*صریح)\b/i,
];
function normalizeText(text) {
if (!text || typeof text !== 'string') return '';
return text
.replace(/[\u200c\u200f]/g, '')
.replace(/\s+/g, ' ')
.trim();
}
function matchesAny(text, patterns) {
const normalized = normalizeText(text);
if (!normalized) return false;
return patterns.some((pattern) => pattern.test(normalized));
}
function containsProfanity(text) {
return matchesAny(text, PROFANITY_PATTERNS);
}
function containsExplicitContent(text) {
return matchesAny(text, EXPLICIT_CONTENT_PATTERNS);
}
/** Comment / vitrine / academy comment status */
function resolveCommentModerationStatus(text) {
if (containsProfanity(text) || containsExplicitContent(text)) {
return 'rejected';
}
return 'temp_accept';
}
/**
* Post moderation:
* - reject: profanity / explicit text in caption
* - temp_accept: visible in app, awaits manual full approval
*/
function resolvePostModerationStatus({ caption, filePaths = [] }) {
if (containsProfanity(caption) || containsExplicitContent(caption)) {
return { status: 'reject', reason: 'caption_violation' };
}
return { status: 'temp_accept', reason: 'awaiting_review' };
}
module.exports = {
containsProfanity,
containsExplicitContent,
resolveCommentModerationStatus,
resolvePostModerationStatus,
};