Commit afe5eeef authored by Robert's avatar Robert

Use sync email backend for synchronous sending of mails

parent 10928d91
Pipeline #1519 passed with stage
in 2 minutes and 21 seconds
......@@ -189,7 +189,9 @@ class Notification:
message.attach_file(file_name)
# optional connection switch
if kwargs.get('use_async_email_backend'):
if kwargs.get('use_sync_email_backend'):
message.connection = get_connection(settings.SYNC_EMAIL_BACKEND)
elif kwargs.get('use_async_email_backend'):
message.connection = get_connection(settings.ASYNC_EMAIL_BACKEND)
# we don't expect errors when sending mails because we just pass mails to django-mailer
......
......@@ -13,6 +13,6 @@ post_create = Signal(providing_args=['instance'])
def content_created(sender, instance, **kwargs):
if now() - instance.versions.last().time_created < timedelta(weeks=1):
# send mails synchronously via default EMAIL_BACKEND
ContentCreated.send_all(instance)
ContentCreated.send_all(instance, use_sync_email_backend=True)
# send mails asynchronously (task queue) via ASYNC_EMAIL_BACKEND
send_content_notifications(instance)
......@@ -11,6 +11,6 @@ post_create = django.dispatch.Signal(providing_args=['instance'])
@receiver(post_create)
def contribution_created(sender, instance, **kwargs):
# send mails synchronously via default EMAIL_BACKEND
ContributionCreated.send_all(instance)
ContributionCreated.send_all(instance, use_sync_email_backend=True)
# send mails asynchronously (task queue) via ASYNC_EMAIL_BACKEND
send_contribution_notifications(instance)
......@@ -191,6 +191,7 @@ GROUPRISE_POSTMASTER_EMAIL = 'postmaster@localhost'
EMAIL_BACKEND = 'mailer.backend.DbBackend'
MAILER_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
SYNC_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
ASYNC_EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
......
......@@ -9,3 +9,5 @@ GROUPRISE_UNKNOWN_GESTALT_ID = 1
HUEY = {
'always_eager': True,
}
SYNC_EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
ASYNC_EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment