diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index 4104c7cbce4e..8aa811a407ba 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -104,4 +104,5 @@ This maintenance release includes the following code fixes: 97. https://github.com/dotCMS/core/issues/27531 : Google Maps does not work on the rules page #27531 98. https://github.com/dotCMS/core/issues/26660 : Fix Menu label if we are missing the translation key #26660 99. https://github.com/dotCMS/core/issues/26283 : Relationship throwing error when the child content is a copy of original child content #26283 -100. https://github.com/dotCMS/core/issues/26597 : Textareas need to be embiggened. #26597 \ No newline at end of file +100. https://github.com/dotCMS/core/issues/26597 : Textareas need to be embiggened. #26597 +101. https://github.com/dotCMS/core/issues/28360 : Move Async Email Actionlet to Core #28360 \ No newline at end of file diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/AsyncEmailActionlet.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/AsyncEmailActionlet.java new file mode 100644 index 000000000000..b377579006ad --- /dev/null +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/AsyncEmailActionlet.java @@ -0,0 +1,46 @@ +package com.dotmarketing.portlets.workflows.actionlet; + +import com.dotcms.api.system.event.message.MessageSeverity; +import com.dotcms.api.system.event.message.SystemMessageEventUtil; +import com.dotcms.api.system.event.message.builder.SystemMessageBuilder; +import com.dotcms.concurrent.DotConcurrentFactory; +import com.dotmarketing.portlets.workflows.model.WorkflowProcessor; +import com.dotmarketing.util.Mailer; + +import java.util.ArrayList; +import java.util.List; + +/** + * Same of the {@link EmailActionlet} but runs asynchronously. + * @author jsanca + */ +public class AsyncEmailActionlet extends EmailActionlet { + + private static final long serialVersionUID = 1L; + + protected final SystemMessageEventUtil systemMessageEventUtil = + SystemMessageEventUtil.getInstance(); + + + @Override + public String getName() { + return "Async Send an Email"; + } + + @Override + protected void sendEmail(final Mailer mail, final WorkflowProcessor processor) { + DotConcurrentFactory.getInstance().getSubmitter().submit(()->{ + try { + mail.sendMessage(); + } catch (Exception e) { + + final List userList = new ArrayList<>(); + userList.add(processor.getUser().getUserId()); + this.systemMessageEventUtil.pushMessage(new SystemMessageBuilder().setMessage("Error sending the email: " + e.getMessage()) + .setLife(5000) + .setSeverity(MessageSeverity.ERROR).create(), userList); + } + }); + } + +} \ No newline at end of file diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/EmailActionlet.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/EmailActionlet.java index 8e031964a8ad..6a8b3f8cbc58 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/EmailActionlet.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/EmailActionlet.java @@ -228,7 +228,7 @@ public void executeAction(WorkflowProcessor processor, Map