Skip to content

Conversation

HaroWana
Copy link

Makes email sending asynchronous by moving email operations to Celery tasks, preventing API endpoints from blocking.

This pull request addresses issue #1143

try:
document = models.Document.objects.get(id=document_id)
document.send_email(subject, emails, context, language)
except models.Document.DoesNotExist:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to not fail silently. Let the exception bubbles, your monitoring system will warn you about this error. Because it is not normal to not find the document here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Removing the try/except clauses should allow the exception to bubble up then, right?
Thank you !

document = models.Document.objects.get(id=document_id)
sender = models.User.objects.get(id=sender_id)
document.send_invitation_email(email, role, sender, language)
except (models.Document.DoesNotExist, models.User.DoesNotExist):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Move send_email and send_invitation_email operations to Celery tasks to prevent API endpoints from blocking while sending emails.

Signed-off-by: Johann LORBER <[email protected]>
@HaroWana HaroWana force-pushed the move_email_to_celery branch from 21e721d to ce02929 Compare September 1, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants