fix: properly check email send result in admin test endpoint
send_raw() returns EmailLog, not boolean - check status=="sent" and return error_message on failure instead of always reporting success. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -659,7 +659,7 @@ def send_test_email(
|
||||
email_service = EmailService(db)
|
||||
|
||||
# Send test email using platform configuration
|
||||
success = email_service.send_raw(
|
||||
email_log = email_service.send_raw(
|
||||
to_email=request.to_email,
|
||||
to_name=None,
|
||||
subject="Wizamart Platform - Test Email",
|
||||
@@ -684,7 +684,8 @@ def send_test_email(
|
||||
is_platform_email=True,
|
||||
)
|
||||
|
||||
if success:
|
||||
# Check if email was actually sent (send_raw returns EmailLog, not boolean)
|
||||
if email_log.status == "sent":
|
||||
# Log action
|
||||
admin_audit_service.log_action(
|
||||
db=db,
|
||||
@@ -703,7 +704,7 @@ def send_test_email(
|
||||
else:
|
||||
return TestEmailResponse(
|
||||
success=False,
|
||||
message="Failed to send test email. Check server logs for details.",
|
||||
message=email_log.error_message or "Failed to send test email. Check server logs for details.",
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user