🔒️(backend) remove personal data from email failure logs

Fix code that accidentally exposed personal email addresses in logs during
email sending failures. Modify logging to remove identifying information
to protect user privacy while still providing useful debugging context.

Original code was inspired by Docs.
This commit is contained in:
lebaudantoine
2025-04-16 19:10:57 +02:00
committed by aleb_the_flash
parent d92adb7435
commit 7021272075
2 changed files with 4 additions and 4 deletions

View File

@@ -83,7 +83,7 @@ class NotificationService:
fail_silently=False,
)
except smtplib.SMTPException as exception:
logger.error("notification to %s was not sent: %s", emails, exception)
logger.error("notification could not be sent: %s", exception)
return False
return True

View File

@@ -150,9 +150,9 @@ def test_notify_user_by_email_smtp_exception(mocked_current_site, caplog):
"""Test email notification when an exception occurs."""
recording = factories.RecordingFactory(room__name="Conference Room A")
owner = factories.UserRecordingAccessFactory(
factories.UserRecordingAccessFactory(
recording=recording, role=models.RoleChoices.OWNER
).user
)
notification_service = NotificationService()
@@ -164,4 +164,4 @@ def test_notify_user_by_email_smtp_exception(mocked_current_site, caplog):
assert result is False
mock_send_mail.assert_called_once()
assert f"notification to ['{owner.email}'] was not sent" in caplog.text
assert "notification could not be sent:" in caplog.text