백기선 2015-04-01
Merge branch 'fix/endless-email' into 'next'
from pull-request 1562

* refs/heads/fix/endless-email:
  mail: Fix the error message while sending a email
  mail: Fix delivery failure under certain condition
  mail: Fix endless notification email

Reviewed-by: 백기선 
@2dff37eeaf374a0940503c0f2753f7c64916b533
app/models/NotificationMail.java
--- app/models/NotificationMail.java
+++ app/models/NotificationMail.java
@@ -114,7 +114,7 @@
                     try {
                         sendMail();
                     } catch (Exception e) {
-                        play.Logger.warn("Failed to send notification mail", e);
+                        play.Logger.warn("Error occured while sending notification mails", e);
                     }
                 }
 
@@ -139,10 +139,15 @@
                                     .orderBy("notificationEvent.created ASC").findList();
 
                     for (NotificationMail mail: mails) {
-                        if (mail.notificationEvent.resourceExists()) {
-                            sendNotification(mail.notificationEvent);
+                        try {
+                            NotificationEvent event = mail.notificationEvent;
+                            mail.delete();
+                            if (event.resourceExists()) {
+                                sendNotification(event);
+                            }
+                        } catch (Exception e) {
+                            play.Logger.warn("Error occured while sending a notification mail", e);
                         }
-                        mail.delete();
                     }
                 }
             },
Add a comment
List