fix(email): detect and surface webhook send failures instead of claiming success
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
send_webhook_email() only returned False on a network exception — a webhook that responded with a non-2xx status (bad URL, wrong API key, misconfigured Power Automate flow) was still reported as delivered. Now checks response.ok and returns False on rejection too. send_password_setup_email() also never checked the return value at all, so the admin's 'Send Email' action (including resending a password-reset email after the user already set their password) always showed success even when nothing was actually sent. Now raises a clear error instead.
This commit is contained in:
@@ -65,7 +65,11 @@ def send_password_setup_email(db: Session, user: User) -> None:
|
||||
f"{set_password_url}\n\n"
|
||||
"This link expires in 24 hours and can only be used once."
|
||||
)
|
||||
send_webhook_email(db, to=user.email, subject=subject, message=message, full_name=user.full_name)
|
||||
sent = send_webhook_email(db, to=user.email, subject=subject, message=message, full_name=user.full_name)
|
||||
if not sent:
|
||||
raise BusinessRuleViolation(
|
||||
"Failed to send the email — check the webhook URL/API key in Settings and the server logs."
|
||||
)
|
||||
|
||||
|
||||
def _get_valid_token_or_raise(db: Session, token: str) -> PasswordSetupToken:
|
||||
|
||||
Reference in New Issue
Block a user