From 852df6b40c3aaf0f44fe9891a7b39a2b392ab5e9 Mon Sep 17 00:00:00 2001 From: KlemenSpruk Date: Fri, 13 Oct 2023 11:09:17 +0200 Subject: [PATCH] =?UTF-8?q?#727=20Sender=20email=20se=20ve=C4=8Dkrat=20po?= =?UTF-8?q?=C5=A1lje=20(#143)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * addes todos * send email to sender only once * updated js import --- .../notifications/base/channels/integrations/aws_ses.py | 4 ++-- .../notifications/base/channels/mail_channel.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/django_project_base/notifications/base/channels/integrations/aws_ses.py b/django_project_base/notifications/base/channels/integrations/aws_ses.py index f4c9c9e9..73bc71bc 100644 --- a/django_project_base/notifications/base/channels/integrations/aws_ses.py +++ b/django_project_base/notifications/base/channels/integrations/aws_ses.py @@ -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, diff --git a/django_project_base/notifications/base/channels/mail_channel.py b/django_project_base/notifications/base/channels/mail_channel.py index dc8d8a88..acf84481 100644 --- a/django_project_base/notifications/base/channels/mail_channel.py +++ b/django_project_base/notifications/base/channels/mail_channel.py @@ -1,3 +1,4 @@ +import uuid from typing import List from django.conf import settings @@ -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=""):