check
This commit is contained in:
@@ -1,63 +1,76 @@
|
||||
/**
|
||||
* Moderation helpers for comments and posts (Persian profanity + explicit cues).
|
||||
*/
|
||||
const { isVerifiedBadge } = require('./verifyBadge')
|
||||
|
||||
const PROFANITY_PATTERNS = [
|
||||
/\b(کس|کیر|کون|جنده|حروم|لاشی|بی\s*شعور|گه|گایید|گائید)\b/i,
|
||||
/\b(fuck|shit|bitch|asshole)\b/i,
|
||||
];
|
||||
/\b(fuck|shit|bitch|asshole)\b/i
|
||||
]
|
||||
|
||||
const EXPLICIT_CONTENT_PATTERNS = [
|
||||
/\b(برهنگ|برهنگی|پورن|porn|nude|naked|sex)\b/i,
|
||||
/\b(سکس|جنسی\s*صریح)\b/i,
|
||||
];
|
||||
/\b(سکس|جنسی\s*صریح)\b/i
|
||||
]
|
||||
|
||||
function normalizeText(text) {
|
||||
if (!text || typeof text !== 'string') return '';
|
||||
function normalizeText (text) {
|
||||
if (!text || typeof text !== 'string') return ''
|
||||
return text
|
||||
.replace(/[\u200c\u200f]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
.trim()
|
||||
}
|
||||
|
||||
function matchesAny(text, patterns) {
|
||||
const normalized = normalizeText(text);
|
||||
if (!normalized) return false;
|
||||
return patterns.some((pattern) => pattern.test(normalized));
|
||||
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 containsProfanity (text) {
|
||||
return matchesAny(text, PROFANITY_PATTERNS)
|
||||
}
|
||||
|
||||
function containsExplicitContent(text) {
|
||||
return matchesAny(text, EXPLICIT_CONTENT_PATTERNS);
|
||||
function containsExplicitContent (text) {
|
||||
return matchesAny(text, EXPLICIT_CONTENT_PATTERNS)
|
||||
}
|
||||
|
||||
/** Comment / vitrine / academy comment status */
|
||||
function resolveCommentModerationStatus(text) {
|
||||
/**
|
||||
* Comment / vitrine / academy comment status.
|
||||
* کاربرِ بدون تیک وریفای (طلایی/سبز/آبی) نباید مستقیم توی اپ/وب نمایش داده بشه —
|
||||
* باید توی پنل ادمین دستی تایید بشه، پس status روش pending میمونه
|
||||
*/
|
||||
function resolveCommentModerationStatus (text, verifyBadge) {
|
||||
if (containsProfanity(text) || containsExplicitContent(text)) {
|
||||
return 'rejected';
|
||||
return 'rejected'
|
||||
}
|
||||
return 'temp_accept';
|
||||
if (!isVerifiedBadge(verifyBadge)) {
|
||||
return 'pending'
|
||||
}
|
||||
return 'temp_accept'
|
||||
}
|
||||
|
||||
/**
|
||||
* Post moderation:
|
||||
* - reject: profanity / explicit text in caption
|
||||
* - temp_accept: visible in app, awaits manual full approval
|
||||
* - pending: creator ندارد تیک وریفای طلایی/سبز/آبی — نیاز به تاییدِ دستیِ پنل داره
|
||||
* - temp_accept: creator وریفایشدهست — مستقیم توی اپ نمایش داده میشه
|
||||
*/
|
||||
function resolvePostModerationStatus({ caption, filePaths = [] }) {
|
||||
function resolvePostModerationStatus ({ caption, filePaths = [], verifyBadge }) {
|
||||
if (containsProfanity(caption) || containsExplicitContent(caption)) {
|
||||
return { status: 'reject', reason: 'caption_violation' };
|
||||
return { status: 'reject', reason: 'caption_violation' }
|
||||
}
|
||||
|
||||
return { status: 'temp_accept', reason: 'awaiting_review' };
|
||||
if (!isVerifiedBadge(verifyBadge)) {
|
||||
return { status: 'pending', reason: 'awaiting_admin_review' }
|
||||
}
|
||||
|
||||
return { status: 'temp_accept', reason: 'awaiting_review' }
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
containsProfanity,
|
||||
containsExplicitContent,
|
||||
resolveCommentModerationStatus,
|
||||
resolvePostModerationStatus,
|
||||
};
|
||||
resolvePostModerationStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user