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
Implementation of the custom email backend to handle SES events #1994
Implementation of the custom email backend to handle SES events #1994
Conversation
for more information, see https://pre-commit.ci
- Added admin files for email models - Moved email logic and signals outside of the models - Rebased with main, (poetry.lock) conflicts solved - Updates and improvements in email models - Other Changes requested solved
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.
I only did a partial review for now, but a couple high level comments and a few detailed once as well:
-
I think the backend applies beyond just users, so I'd put it in
cl.lib.email_backends.py
instead. (Note that I made it plural too, in case someday we have another backend for some reason.) -
Should we have an admin page for the
Email
table? -
Wow, tests!
Thanks for this. Looking good.
Thank you so much for your comments! |
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.
Lots of little stuff. I still don't love some of the deep nesting and long functions you have here. I think we may just decide it's fine, but one opportunity I did see was to simplify the store_message and compose_message functions.
Anyhow, let me know what you think.
Thank you for your comments! I think these changes are ready, I left some comments above, let me know if there is something more to change. There's a problem with our black version to parse the new parenthesized context managers #1994 (comment) |
In doing this, MyPy complained that the super class expected an int to be returned, so I implemented that.
Tests are still going, but this isn't a merge into |
This is a custom email backend to handle sending an email with some extra functions before the email is sent.
It's necessary to set the following settings:
BASE_BACKEND
: The base email backend to use to send emails, in our case:django_ses.SESBackend
, for testing, is used:django.core.mail.backends.locmem.EmailBackend
MAX_ATTACHMENT_SIZE
: The maximum file size in bytes that an attachment can have to be sent.The backend supports storing only one email address for the recipient, bcc, and cc fields.
The verifications that the backend performs (email banned and backoff events) are not supported for messages with one recipient.
I saw that in general CL messages are sent to only one recipient, however, I found this command:
cl.alerts.management.commands.monitor_pacer
That seems to send emails to multiple recipients in the same message, using this email backend messages will be sent, however since we only store one recipient, verifications for email banned and backoff events are not supported.
One approach to solve this problem could be to change this command to send one message for each recipient, like this one:
cl.users.management.commands.cl_welcome_new_users