From ab35cf9126cabf3fdb0f7bd5c1691427581a608b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 10 Mar 2026 14:37:24 -0300 Subject: [PATCH] fix: resolve smtp authentication error and notification issues - Stripped literal quotes from SMTP credentials in nodemailer config to prevent '535 Incorrect auth data' in Docker Swarm. - Reduced notification polling interval from 60s to 10s for real-time updates. - Fixed browser autoplay block for audio notifications by properly initializing the audio context. --- backend/index.js | 4 ++-- components/Layout.tsx | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/backend/index.js b/backend/index.js index 491396b..2469f33 100644 --- a/backend/index.js +++ b/backend/index.js @@ -19,8 +19,8 @@ const transporter = nodemailer.createTransport({ port: parseInt(process.env.SMTP_PORT) || 587, secure: false, // false para 587 (STARTTLS) auth: { - user: process.env.SMTP_USER || 'nao-responda@blyzer.com.br', - pass: process.env.SMTP_PASS || 'Compor@2017#', // Fallback to your known prod pass if env fails in swarm + user: (process.env.SMTP_USER || 'nao-responda@blyzer.com.br').replace(/^"|"$/g, ''), + pass: (process.env.SMTP_PASS || 'Compor@2017#').replace(/^"|"$/g, ''), }, tls: { ciphers: 'SSLv3', diff --git a/components/Layout.tsx b/components/Layout.tsx index 1efd334..b819f68 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -46,12 +46,24 @@ export const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => const unreadCount = notifications.filter(n => !n.is_read).length; const previousUnreadCountRef = React.useRef(0); const isInitialLoadRef = React.useRef(true); + + // Pre-initialize audio to ensure it's loaded and ready + const audioRef = React.useRef(null); + useEffect(() => { + // Determine base path correctly whether in prod or dev + const basePath = import.meta.env.PROD ? '' : 'http://localhost:3001'; + audioRef.current = new Audio(`${basePath}/audio/notification.mp3`); + audioRef.current.volume = 0.5; + }, []); const playNotificationSound = () => { - if (currentUser?.sound_enabled !== false) { - const audio = new Audio('/audio/notification.mp3'); - audio.volume = 0.5; - audio.play().catch(e => console.log('Audio play failed:', e)); + if (currentUser?.sound_enabled !== false && audioRef.current) { + // Reset time to 0 to allow rapid replays + audioRef.current.currentTime = 0; + const playPromise = audioRef.current.play(); + if (playPromise !== undefined) { + playPromise.catch(e => console.log('Audio play blocked by browser policy:', e)); + } } };