File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from django .utils import timezone
66
77from api .base import settings as api_settings
8+ from website import settings as osf_settings
89from osf import email , features
910
1011
@@ -21,7 +22,6 @@ class Notification(models.Model):
2122
2223 def send (
2324 self ,
24- protocol_type = 'email' ,
2525 destination_address = None ,
2626 email_context = None ,
2727 save = True ,
@@ -36,22 +36,28 @@ def send(
3636 f"\n context={ self .event_context } "
3737 f"\n email_context={ email_context } "
3838 )
39- if protocol_type == 'email' and waffle .switch_is_active (features .ENABLE_MAILHOG ):
39+
40+ if waffle .switch_is_active (features .ENABLE_MAILHOG ):
4041 email .send_email_over_smtp (
4142 recipient_address ,
4243 self .subscription .notification_type ,
4344 self .event_context ,
4445 email_context
4546 )
46- elif protocol_type == 'email' :
47+
48+ if not osf_settings .LOCAL_MODE :
4749 email .send_email_with_send_grid (
4850 recipient_address ,
4951 self .subscription .notification_type ,
5052 self .event_context ,
5153 email_context
5254 )
53- else :
54- raise NotImplementedError (f'protocol `{ protocol_type } ` is not supported.' )
55+
56+ if osf_settings .LOCAL_MODE and not waffle .switch_is_active (features .ENABLE_MAILHOG ):
57+ logging .warning (
58+ 'Both ENABLE_MAILHOG and LOCAL_MODE are disabled. Emails will not be sent to MailHog or real email addresses. '
59+ 'Turn on ENABLE_MAILHOG to send emails to MailHog for testing, or turn on LOCAL_MODE to send emails with SendGrid.'
60+ )
5561
5662 if save :
5763 self .mark_sent ()
You can’t perform that action at this time.
0 commit comments