Update main.js
This commit is contained in:
parent
af6e52cd99
commit
01d74db92f
|
@ -248,26 +248,49 @@ const contentModeration = new ContentModeration();
|
||||||
// Função para processar arquivos recebidos
|
// Função para processar arquivos recebidos
|
||||||
async function handleReceivedFile(file) {
|
async function handleReceivedFile(file) {
|
||||||
try {
|
try {
|
||||||
// Verifica se o conteúdo é NSFW
|
console.log('Processando arquivo:', file.name, file.type);
|
||||||
const isNSFW = await contentModeration.checkNSFW(file);
|
|
||||||
if (isNSFW) {
|
// Verifica se é uma imagem ou vídeo
|
||||||
const shouldView = await contentModeration.showWarningDialog(file, 'explicit');
|
if (file.type.startsWith('image/') || file.type.startsWith('video/')) {
|
||||||
if (!shouldView) return;
|
console.log('Verificando conteúdo NSFW...');
|
||||||
|
const isNSFW = await contentModeration.checkNSFW(file);
|
||||||
|
console.log('Resultado NSFW:', isNSFW);
|
||||||
|
|
||||||
|
if (isNSFW) {
|
||||||
|
console.log('Conteúdo explícito detectado, mostrando aviso...');
|
||||||
|
// Cria elemento borrado
|
||||||
|
const mediaElement = document.createElement(file.type.startsWith('image/') ? 'img' : 'video');
|
||||||
|
mediaElement.className = 'media-preview blurred-content';
|
||||||
|
mediaElement.src = URL.createObjectURL(file);
|
||||||
|
|
||||||
|
// Aplica blur e overlay
|
||||||
|
contentModeration.applyBlurAndOverlay(mediaElement, 'explicit');
|
||||||
|
|
||||||
|
// Mostra diálogo de aviso
|
||||||
|
const shouldView = await contentModeration.showWarningDialog(file, 'explicit');
|
||||||
|
if (!shouldView) {
|
||||||
|
console.log('Usuário recusou visualizar o conteúdo');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifica se é spam
|
// Verifica nome do arquivo por spam/ofensas
|
||||||
if (contentModeration.isSpam(file.name).isSpam) {
|
const spamCheck = contentModeration.isSpam(file.name);
|
||||||
const shouldView = await contentModeration.showWarningDialog(file, 'spam');
|
const hasOffensiveWords = contentModeration.hasBlockedWordsWithSubstitutions(file.name);
|
||||||
if (!shouldView) return;
|
|
||||||
|
if (spamCheck.isSpam || hasOffensiveWords) {
|
||||||
|
console.log('Nome do arquivo contém conteúdo impróprio');
|
||||||
|
const contentType = hasOffensiveWords ? 'offensive' : 'spam';
|
||||||
|
const shouldView = await contentModeration.showWarningDialog(file, contentType);
|
||||||
|
if (!shouldView) {
|
||||||
|
console.log('Usuário recusou visualizar o arquivo');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifica se contém linguagem ofensiva
|
// Se chegou aqui, processa o arquivo normalmente
|
||||||
if (contentModeration.hasBlockedWordsWithSubstitutions(file.name)) {
|
console.log('Processando arquivo normalmente');
|
||||||
const shouldView = await contentModeration.showWarningDialog(file, 'offensive');
|
|
||||||
if (!shouldView) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Processa o arquivo normalmente
|
|
||||||
processFile(file);
|
processFile(file);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro ao processar arquivo:', error);
|
console.error('Erro ao processar arquivo:', error);
|
||||||
|
|
Loading…
Reference in New Issue