Yi EungJun 2015-04-01
mail: Fix endless notification email
Yobi was sending a notification email endlessly if it failed to delete
the email from the sending queue. It may happen if the database is
corrupted.

Do not send the notification email if an exception was thrown when
deleting it from the queue(notification_email table).
@2799c86c336e29fbebb4ab5f5a0afc24c0434065
app/models/NotificationMail.java
--- app/models/NotificationMail.java
+++ app/models/NotificationMail.java
@@ -139,10 +139,11 @@
                                     .orderBy("notificationEvent.created ASC").findList();
 
                     for (NotificationMail mail: mails) {
-                        if (mail.notificationEvent.resourceExists()) {
-                            sendNotification(mail.notificationEvent);
-                        }
+                        NotificationEvent event = mail.notificationEvent;
                         mail.delete();
+                        if (event.resourceExists()) {
+                            sendNotification(event);
+                        }
                     }
                 }
             },
Add a comment
List