From 2799c86c336e29fbebb4ab5f5a0afc24c0434065 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Wed, 1 Apr 2015 13:59:40 +0900 Subject: [PATCH] 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). --- app/models/NotificationMail.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/NotificationMail.java b/app/models/NotificationMail.java index 64115b54f..4187ca082 100644 --- a/app/models/NotificationMail.java +++ b/app/models/NotificationMail.java @@ -139,10 +139,11 @@ private void sendMail() { .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); + } } } },