From 5f95e6b46bc8f975a409eb990d7d2425449db444 Mon Sep 17 00:00:00 2001 From: Jens Hardings Date: Fri, 8 Mar 2024 12:59:04 -0300 Subject: [PATCH 1/2] Add send#PendingEmails service which looks up and sends emails ready to be sent, within max number of attempts --- framework/entity/BasicEntities.xml | 2 + .../service/org/moqui/impl/EmailServices.xml | 60 +++++++++++++++++++ .../org/moqui/impl/sendEmailMessage.groovy | 3 + 3 files changed, 65 insertions(+) diff --git a/framework/entity/BasicEntities.xml b/framework/entity/BasicEntities.xml index d71b77fc5..811dd5ef8 100644 --- a/framework/entity/BasicEntities.xml +++ b/framework/entity/BasicEntities.xml @@ -554,6 +554,8 @@ along with this software (see the LICENSE.md file). If not, see For outgoing messages that came from an EmailTemplate. + + diff --git a/framework/service/org/moqui/impl/EmailServices.xml b/framework/service/org/moqui/impl/EmailServices.xml index b08b328d4..fcc510bc3 100644 --- a/framework/service/org/moqui/impl/EmailServices.xml +++ b/framework/service/org/moqui/impl/EmailServices.xml @@ -26,6 +26,7 @@ along with this software (see the LICENSE.md file). If not, see + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/src/main/resources/org/moqui/impl/sendEmailMessage.groovy b/framework/src/main/resources/org/moqui/impl/sendEmailMessage.groovy index 2e0b1373c..30e58682f 100644 --- a/framework/src/main/resources/org/moqui/impl/sendEmailMessage.groovy +++ b/framework/src/main/resources/org/moqui/impl/sendEmailMessage.groovy @@ -149,6 +149,9 @@ try { } catch (Throwable t) { logger.error("Error in sendEmailTemplate", t) ec.message.addMessage("Error sending email: ${t.toString()}") + ec.service.sync().name("update", "moqui.basic.email.EmailMessage").requireNewTransaction(true) + .parameters([emailMessageId:emailMessageId, lastSendAttemptDate:ec.user.nowTimestamp, sendAttemptCount:((emailMessage.sendAttemptCount?:0)+1)]) + .disableAuthz().call() } return From 220976d15d7dc49aac586994b47abb35d051c4d5 Mon Sep 17 00:00:00 2001 From: Jens Hardings Date: Mon, 22 Apr 2024 11:41:30 -0400 Subject: [PATCH 2/2] fix: In org.moqui.impl.EmailServices.send#PendingEmails, only attempt to send if toAddresses and fromAddress fields are defined --- framework/service/org/moqui/impl/EmailServices.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/framework/service/org/moqui/impl/EmailServices.xml b/framework/service/org/moqui/impl/EmailServices.xml index fcc510bc3..b753b5153 100644 --- a/framework/service/org/moqui/impl/EmailServices.xml +++ b/framework/service/org/moqui/impl/EmailServices.xml @@ -134,12 +134,16 @@ along with this software (see the LICENSE.md file). If not, see + + + + @@ -147,6 +151,8 @@ along with this software (see the LICENSE.md file). If not, see + +