Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Jan 25, 2025
1 parent 996494a commit ee99fb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions backend/ciso_assistant/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ def set_ciso_assistant_url(_, __, event_dict):
},
}

if DEBUG:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
DEFAULT_FROM_EMAIL = "[email protected]"

# for dev: docker run -d -p 6379:6379 redis:alpine
## Huey settings
HUEY = {
Expand Down
19 changes: 13 additions & 6 deletions backend/core/tasks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from datetime import date, datetime, timezone
from datetime import date
from huey import crontab
from huey.contrib.djhuey import periodic_task, task, db_periodic_task, db_task
from core.models import AppliedControl
from django.db.models import Q

from django.core.mail import send_mail
from django.conf import settings

# basic placeholders from the official doc
# https://huey.readthedocs.io/en/latest/django.html
Expand Down Expand Up @@ -32,10 +33,16 @@ def check_controls_with_expired_eta():

@task()
def send_notification_email(owner_email, controls):
subject = f"You have {len(controls)} expired controls"
subject = f"CISO Assistant: You have {len(controls)} expired control(s)"
message = "The following controls have expired:\n\n"
for control in controls:
message += f"- {control.name} (ETA: {control.eta})\n"

print(f"Sending email to {owner_email}")
print(message)
message += "\nThis reminder will stop once the control is marked as active or you update the ETA.\n"
# think templating and i18n
send_mail(
subject=subject,
message=message,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[owner_email],
fail_silently=False,
)

0 comments on commit ee99fb8

Please sign in to comment.