From 927ea709de6052ebf65ef23985334eeac93e5273 Mon Sep 17 00:00:00 2001
From: ErikrafT <139592038+erikraft@users.noreply.github.com>
Date: Wed, 7 May 2025 16:37:27 -0300
Subject: [PATCH] Update content-moderation.js
---
public/scripts/content-moderation.js | 204 +++++++++++++++------------
1 file changed, 113 insertions(+), 91 deletions(-)
diff --git a/public/scripts/content-moderation.js b/public/scripts/content-moderation.js
index bc92517..10c007e 100644
--- a/public/scripts/content-moderation.js
+++ b/public/scripts/content-moderation.js
@@ -322,100 +322,122 @@ class ContentModeration {
}
// Mostra o diálogo de aviso
- showWarningDialog(file, contentType = 'spam') {
- const dialog = document.createElement('div');
- dialog.className = 'content-warning-dialog';
-
- // Define o ícone e mensagem baseado no tipo de conteúdo
- let icon, title, message;
- switch (contentType) {
- case 'explicit':
- icon = ``;
- title = 'Conteúdo Explícito';
- message = 'Este conteúdo pode conter material adulto ou impróprio';
- break;
- case 'profanity':
- icon = ``;
- title = 'Linguagem Imprópria';
- message = 'Este conteúdo contém linguagem ofensiva ou inadequada';
- break;
- case 'scam':
- icon = ``;
- title = 'Possível Golpe';
- message = 'Este conteúdo pode ser uma tentativa de golpe ou fraude';
- break;
- default:
- icon = ``;
- title = 'Possível Spam';
- message = 'Este conteúdo pode ser spam ou tentativa de golpe';
- }
-
- const content = document.createElement('div');
- content.className = 'warning-content';
- content.innerHTML = `
-
- ${icon}
-
-
-
${title}
-
${message}
-
-
-
-
-
-
- `;
-
- dialog.appendChild(content);
- document.body.appendChild(dialog);
-
- // Adiciona eventos aos botões
- const cancelBtn = content.querySelector('.btn-cancel');
- const viewBtn = content.querySelector('.btn-view');
- const mediaPreview = content.querySelector('.media-preview');
-
- cancelBtn.onclick = () => {
- dialog.remove();
- URL.revokeObjectURL(mediaPreview.querySelector('img, video').src);
- };
-
- viewBtn.onclick = () => {
- mediaPreview.classList.remove('blurred');
- viewBtn.style.display = 'none';
- cancelBtn.textContent = 'Fechar';
- };
-
- // Adiciona evento para fechar com ESC
- document.addEventListener('keydown', function escHandler(e) {
- if (e.key === 'Escape') {
- dialog.remove();
- URL.revokeObjectURL(mediaPreview.querySelector('img, video').src);
- document.removeEventListener('keydown', escHandler);
+ async showWarningDialog(file, contentType = 'spam') {
+ return new Promise((resolve) => {
+ const dialog = document.createElement('div');
+ dialog.className = 'content-moderation-warning';
+
+ let title, message, icon;
+
+ switch(contentType) {
+ case 'explicit':
+ title = '🚫 Conteúdo Explícito Detectado';
+ message = 'Este conteúdo pode conter material explícito ou inadequado. Tem certeza que deseja visualizar?';
+ icon = ``;
+ break;
+ case 'spam':
+ title = '🚫 Possível Spam/Golpe Detectado';
+ message = 'Este conteúdo pode ser spam ou tentativa de golpe. Deseja visualizar mesmo assim?';
+ icon = ``;
+ break;
+ case 'offensive':
+ title = '🚫 Conteúdo Ofensivo Detectado';
+ message = 'Este conteúdo contém linguagem ofensiva. Deseja visualizar mesmo assim?';
+ icon = ``;
+ break;
}
+
+ dialog.innerHTML = `
+ ${icon}
+ ${title}
+ ${message}
+
+
+
+
+ `;
+
+ document.body.appendChild(dialog);
+
+ const viewButton = dialog.querySelector('.warning-button.view');
+ const rejectButton = dialog.querySelector('.warning-button.reject');
+
+ viewButton.onclick = () => {
+ document.body.removeChild(dialog);
+ resolve(true);
+ };
+
+ rejectButton.onclick = () => {
+ document.body.removeChild(dialog);
+ resolve(false);
+ };
+
+ // Fecha o diálogo com ESC
+ document.addEventListener('keydown', function escHandler(e) {
+ if (e.key === 'Escape') {
+ document.body.removeChild(dialog);
+ document.removeEventListener('keydown', escHandler);
+ resolve(false);
+ }
+ });
});
}
+ // Aplica blur e overlay em conteúdo sensível
+ applyBlurAndOverlay(element, contentType) {
+ element.classList.add('blurred-content');
+
+ const overlay = document.createElement('div');
+ overlay.className = 'warning-overlay';
+
+ let icon, text;
+ switch(contentType) {
+ case 'explicit':
+ icon = ``;
+ text = 'Conteúdo Explícito Detectado';
+ break;
+ case 'spam':
+ icon = ``;
+ text = 'Possível Spam/Golpe Detectado';
+ break;
+ case 'offensive':
+ icon = ``;
+ text = 'Conteúdo Ofensivo Detectado';
+ break;
+ }
+
+ overlay.innerHTML = `
+ ${icon}
+ ${text}
+ `;
+
+ element.appendChild(overlay);
+ }
+
+ // Processa notificações push
+ processPushNotification(notification) {
+ const text = notification.body || '';
+
+ if (this.hasBlockedWordsWithSubstitutions(text) || this.isSpam(text)) {
+ notification.body = '🚫 CONTEÚDO BLOQUEADO';
+ notification.icon = '/images/warning-icon.png';
+ }
+
+ return notification;
+ }
+
// Processa um arquivo antes de enviar
async processFile(file) {
try {
@@ -466,7 +488,7 @@ class ContentModeration {
// Adiciona estilos para o diálogo de aviso
const style = document.createElement('style');
style.textContent = `
- .content-warning-dialog {
+ .content-moderation-warning {
position: fixed;
top: 0;
left: 0;