Skip to content

Commit

Permalink
send email to sender only once
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenSpruk committed Oct 11, 2023
1 parent 3a8f0b4 commit aa3a977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def client_send(self, sender: str, recipient: Recipient, msg: dict, dlr_id: str)
.client("ses")
.send_email(
Destination={
"ToAddresses": [sender],
"ToAddresses": [recipient.email],
"CcAddresses": [],
"BccAddresses": [recipient.email],
"BccAddresses": [],
},
Message=msg,
Source=sender,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from typing import List

from django.conf import settings
Expand All @@ -24,6 +25,14 @@ def send(self, notification: DjangoProjectBaseNotification, extra_data, **kwargs
list(map(int, notification.recipients.split(","))) if notification.recipients else []
)
return len(recipients)
message = self.provider.get_message(notification)
sender = self.sender(notification)
self.provider.client_send(
self.sender(notification),
Recipient(identifier=str(uuid.uuid4()), phone_number="", email=sender),
message,
str(uuid.uuid4()),
)
return super().send(notification=notification, extra_data=extra_data)

def get_recipients(self, notification: DjangoProjectBaseNotification, unique_identifier=""):
Expand Down

0 comments on commit aa3a977

Please sign in to comment.