djangoindia / djangoindia.org

Official website of djangoindia community.
https://djangoindia.org
MIT License
106 stars 48 forks source link

[BUG] Server crash due to lack of background task for `send_mass_email` at event registration #230

Open DevilsAutumn opened 2 weeks ago

DevilsAutumn commented 2 weeks ago

Description

Not sure can we reproduce this on local. But i suspect the problem is in this method.For large number of users, the url becomes too long that it breaks the nginx(I am not sure if this is the exact reason though). Plus this mail is not even stored anywhere which is inefficient. We must store every type communication we are having with the users.

Steps to Reproduce

na

Expected Behavior

na

Actual Behavior

na

Additional Context

No response

Affected Area

Backend

Version

No response

Browser (if frontend)

No response

salty-ivy commented 2 weeks ago

I will investigate this.

salty-ivy commented 3 days ago

Its regression from previous work over EventAdmin and send_email.

Issue 1

send_email_to_selected_users used in send_email_to_selected_users uses built in send_maass_email. which is not being handled separately by background worker and crashes the server.

Solution

We need to handle this via celery as a background task, perhaps make a whole mini interface framework for all the emails to be a task by default.

Issue 2

We would also want to store the email info we are sending to users at different workflow events. currently this is being handled by Update model though I would argue structural approach will save use the unnecessary queries.

Solution

We should create a separate template dir containing different email HTML (jinja) templates with place holders and use render_to_string to convert it into customised string to be passed in email_body parameter for send_email function.

This also helps us beautify emails with HTML and CSS.

CC: @DevilsAutumn