Update content-moderation.js

This commit is contained in:
ErikrafT 2025-05-07 18:52:12 -03:00 committed by GitHub
parent b6dee67c0e
commit 9adc817625
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 40 additions and 39 deletions

View File

@ -434,50 +434,51 @@ class ContentModeration {
// Processa notificações push // Processa notificações push
processPushNotification(notification) { processPushNotification(notification) {
const text = notification.body || ''; const text = notification.body || '';
// Verifica se o texto contém conteúdo ofensivo // Verifica se o texto contém conteúdo ofensivo
const spamCheck = this.isSpam(text); const spamCheck = this.isSpam(text);
if (spamCheck.isSpam) { if (spamCheck.isSpam) {
// Substitui o texto ofensivo por uma mensagem genérica try {
notification.title = 'Aviso de Moderação'; notification.title = 'Aviso de Moderação';
notification.icon = '/images/warning-icon.png'; notification.icon = '/images/warning-icon.png';
// Mensagens específicas para cada tipo de conteúdo
// Mensagens específicas para cada tipo de conteúdo switch(spamCheck.contentType) {
switch(spamCheck.contentType) { case 'explicit':
case 'explicit': notification.body = '🚫 Conteúdo Explícito Bloqueado';
notification.body = '🚫 Conteúdo Explícito Bloqueado'; break;
break; case 'spam':
case 'spam': notification.body = '🚫 Possível Spam/Golpe Detectado';
notification.body = '🚫 Possível Spam/Golpe Detectado'; break;
break; case 'offensive':
case 'offensive': notification.body = '🚫 Conteúdo Ofensivo Detectado';
notification.body = '🚫 Conteúdo Ofensivo Detectado'; break;
break; case 'scam':
case 'scam': notification.body = '🚫 Possível Golpe Detectado';
notification.body = '🚫 Possível Golpe Detectado'; break;
break; default:
default: notification.body = '🚫 Conteúdo Bloqueado';
notification.body = '🚫 Conteúdo Bloqueado'; }
// Adiciona um timestamp para evitar duplicatas
notification.tag = `blocked-${Date.now()}`;
notification.options = {
...notification.options,
requireInteraction: true,
vibrate: [200, 100, 200],
actions: [
{
action: 'close',
title: 'Fechar'
}
]
};
// Se por algum motivo não for possível definir o body ou o ícone, retorna null para ocultar a notificação
if (!notification.body || !notification.icon) {
return null;
}
} catch (e) {
// Em caso de erro, oculta a notificação
return null;
} }
// Adiciona um timestamp para evitar duplicatas
notification.tag = `blocked-${Date.now()}`;
// Adiciona opções extras para a notificação
notification.options = {
...notification.options,
requireInteraction: true,
vibrate: [200, 100, 200],
actions: [
{
action: 'close',
title: 'Fechar'
}
]
};
} }
return notification; return notification;
} }