metallkart-erp/scripts/test-email-direct.sh
louis bdd819efd0 docs(router): email channel diagnostic — no bug, quiet hours behavior
EMAIL channel works correctly. The 5 EXPIRED from supervisor test
were emails successfully sent but unacked (terminal channel).
URGENT bypasses quiet hours (22h-7h UTC) and EMAIL sends fine.
No code fix needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-29 02:37:34 +04:00

32 lines
1.1 KiB
Bash

#!/bin/bash
set -e
cd /opt/erp/metallkart-erp
COOKIE_JAR=/tmp/mk-admin-cookies.txt
# Login
curl -s -X POST http://localhost:3001/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"gruart@cifem-rus.ru","password":"MetallKart2026!"}' \
-c "$COOKIE_JAR" -o /dev/null
echo "=== Test EMAIL channel ==="
RESULT=$(curl -s -X POST http://localhost:3001/api/v1/notification-router/admin/test-dispatch \
-H "Content-Type: application/json" \
-b "$COOKIE_JAR" \
-d '{"targetUserId":"ebdd4d55-9aeb-45c3-a0b4-577dafbab887","channel":"EMAIL","title":"Test EMAIL direct 29/05","body":"Validation canal email du router","priority":"HIGH"}')
echo "Result: $RESULT"
echo ""
echo "=== Latest EMAIL deliveries ==="
docker exec postgres-staging psql -U metallkart -d erp_staging -c "
SELECT id, channel::text, status::text, LEFT(\"failureReason\", 80) AS err, \"sentAt\", \"failedAt\"
FROM notification_deliveries
WHERE channel = 'EMAIL'
ORDER BY \"createdAt\" DESC LIMIT 3
"
echo ""
echo "=== Backend logs (email/smtp) ==="
tail -50 /tmp/erp-backend.log | grep -iE "email|smtp|sendMail|nodemailer|erp_bot" || echo "(no email logs found)"