Skip to content

Commit

Permalink
error when wrapping send_email_message as a huey task
Browse files Browse the repository at this point in the history
  • Loading branch information
ramibch committed Jan 4, 2024
1 parent c7abb81 commit 06c1608
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 8 additions & 0 deletions core/email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from utils.telegram import report_to_admin


def send_email_message(m):
try:
m.send(fail_silently=False)
except Exception as e:
report_to_admin(f"Failed to send email to {m.to}: \n\n {e}")
3 changes: 2 additions & 1 deletion core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from .models.users import UserPremiumPlan, User
from .models.plans import PremiumPlan
from .tasks import send_email_message
from .email import send_email_message


from djstripe.models import Event

Expand Down
12 changes: 2 additions & 10 deletions core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@
from django.conf import settings

from huey import crontab
from huey.contrib.djhuey import db_periodic_task, db_task, task
from huey.contrib.djhuey import db_periodic_task, db_task
from allauth.account.models import EmailAddress

from .models.profiles import Profile
from utils.telegram import report_to_admin


@task
def send_email_message(m):
try:
m.send(fail_silently=False)
except Exception as e:
report_to_admin(f"Failed to send email to {m.to}: \n\n {e}")
from .email import send_email_message


@db_periodic_task(crontab(hour="0", minute="5"))
Expand Down

0 comments on commit 06c1608

Please sign in to comment.