From 3ae45a94c6c2974ad5dd712606e113e1af95f19d Mon Sep 17 00:00:00 2001
From: Matthieu Fesselier <matthieu.fesselier@gmail.com>
Date: Tue, 11 Jun 2019 10:06:44 +0800
Subject: [PATCH] bugfix: send email only when notif created

---
 djangoldp_notification/models.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/djangoldp_notification/models.py b/djangoldp_notification/models.py
index 7f8b4ca..bb28c47 100644
--- a/djangoldp_notification/models.py
+++ b/djangoldp_notification/models.py
@@ -74,8 +74,8 @@ def send_request(target, object_iri):
 
 
 @receiver(post_save, sender=Notification)
-def send_email_on_notification(sender, instance, **kwargs):
-    if instance.summary and settings.JABBER_DEFAULT_HOST and instance.user.email:
+def send_email_on_notification(sender, instance, created, **kwargs):
+    if created and instance.summary and settings.JABBER_DEFAULT_HOST and instance.user.email:
         html_message = loader.render_to_string(
             'email.html',
             {
-- 
GitLab