-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add incident for SMTP errors #5704
Conversation
|
||
def send(self, recipients: list, subject: str, template: str, context: dict): | ||
""" | ||
Sends a multi-part email rendered from templates for the text and html parts. `template` should be the name of | ||
the template, without .html or .txt (e.g. 'channels/email/power_charging'). | ||
""" | ||
from temba.notifications.incidents.builtin import OrgSMTPFailedIncidentType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid circular imports
temba/utils/email/send.py
Outdated
send_email(recipients, subject, text, html, self.from_email, self.connection) | ||
try: | ||
send_email(recipients, subject, text, html, self.from_email, self.connection) | ||
except smtplib.SMTPException: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extended to catch all SMTPException
not just SMTPAuthenticationError
OrgSMTPFailedIncidentType.get_or_create(self.org) | ||
return | ||
except Exception as e: | ||
raise e | ||
OrgSMTPFailedIncidentType.find_and_end(self.org) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this here to avoid the repetition everywhere we send emails
self.branding = branding | ||
self.connection = connection # can be none to use default Django email connection | ||
self.from_email = from_email if from_email else getattr(settings, "DEFAULT_FROM_EMAIL", "[email protected]") | ||
self.org = org |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added org so we can make the incident for the correct org, however we do not have org all them time such as the case for user forget password view, in that case we cannot create an incident.
b014455
to
7015fc0
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5704 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 572 573 +1
Lines 25925 26383 +458
==========================================
+ Hits 25925 26383 +458 ☔ View full report in Codecov by Sentry. |
7015fc0
to
44b21fb
Compare
No description provided.