Skip to content

Commit

Permalink
#28360 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed May 24, 2024
1 parent 3b79537 commit aece999
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 34 deletions.
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
@@ -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<String> 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);
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,16 @@ public void executeAction(WorkflowProcessor processor, Map<String, WorkflowActio
}
}

mail.sendMessage();
sendEmail(mail, processor);

} catch (Exception e) {
Logger.error(EmailActionlet.class, e.getMessage(), e);
}

}

protected void sendEmail(final Mailer mail, final WorkflowProcessor processor) {
mail.sendMessage();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,7 @@
import com.dotmarketing.portlets.structure.model.Structure;
import com.dotmarketing.portlets.workflows.LargeMessageActionlet;
import com.dotmarketing.portlets.workflows.MessageActionlet;
import com.dotmarketing.portlets.workflows.actionlet.Actionlet;
import com.dotmarketing.portlets.workflows.actionlet.ArchiveContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.BatchAction;
import com.dotmarketing.portlets.workflows.actionlet.CheckURLAccessibilityActionlet;
import com.dotmarketing.portlets.workflows.actionlet.CheckinContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.CheckoutContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.CommentOnWorkflowActionlet;
import com.dotmarketing.portlets.workflows.actionlet.CopyActionlet;
import com.dotmarketing.portlets.workflows.actionlet.DeleteContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.DestroyContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.EmailActionlet;
import com.dotmarketing.portlets.workflows.actionlet.FourEyeApproverActionlet;
import com.dotmarketing.portlets.workflows.actionlet.MoveContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.MultipleApproverActionlet;
import com.dotmarketing.portlets.workflows.actionlet.NotifyAssigneeActionlet;
import com.dotmarketing.portlets.workflows.actionlet.NotifyUsersActionlet;
import com.dotmarketing.portlets.workflows.actionlet.PublishContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.PushNowActionlet;
import com.dotmarketing.portlets.workflows.actionlet.PushPublishActionlet;
import com.dotmarketing.portlets.workflows.actionlet.ReindexContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.ResetApproversActionlet;
import com.dotmarketing.portlets.workflows.actionlet.ResetTaskActionlet;
import com.dotmarketing.portlets.workflows.actionlet.SaveContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.SaveContentAsDraftActionlet;
import com.dotmarketing.portlets.workflows.actionlet.SendFormEmailActionlet;
import com.dotmarketing.portlets.workflows.actionlet.SetValueActionlet;
import com.dotmarketing.portlets.workflows.actionlet.TranslationActionlet;
import com.dotmarketing.portlets.workflows.actionlet.TwitterActionlet;
import com.dotmarketing.portlets.workflows.actionlet.UnarchiveContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.UnpublishContentActionlet;
import com.dotmarketing.portlets.workflows.actionlet.VelocityScriptActionlet;
import com.dotmarketing.portlets.workflows.actionlet.WorkFlowActionlet;
import com.dotmarketing.portlets.workflows.actionlet.*;
import com.dotmarketing.portlets.workflows.model.SystemActionWorkflowActionMapping;
import com.dotmarketing.portlets.workflows.model.WorkflowAction;
import com.dotmarketing.portlets.workflows.model.WorkflowActionClass;
Expand Down Expand Up @@ -261,6 +230,7 @@ public WorkflowAPIImpl() {
PushPublishActionlet.class,
CheckURLAccessibilityActionlet.class,
EmailActionlet.class,
AsyncEmailActionlet.class,
SetValueActionlet.class,
ReindexContentActionlet.class,
PushNowActionlet.class,
Expand Down

0 comments on commit aece999

Please sign in to comment.