Skip to content

Commit

Permalink
hotfix(#1217): usertask notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoesle committed Jan 16, 2024
1 parent 139bede commit 3a4a499
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,6 @@ public class UserTaskNotificationListener {
public void delegateTask(final DelegateTask delegateTask) throws Exception {
// send notification on task creation for candidate users and groups
if (delegateTask.getEventName().equals("create")) {
log.debug("Notification for created task: {}", delegateTask.getName());
val notifyCandidateUsers = NOTIFICATION_SEND_CANDIDATE_USERS.from(delegateTask).getOptional();
val notifyCandidateUsersV02 = ProcessTaskConstants.APP_NOTIFICATION_SEND_CANDIDATE_USERS.from(delegateTask).getOptional();
if ((!notifyCandidateUsers.isPresent() || "true".equals(notifyCandidateUsers.get()))
&& (!notifyCandidateUsersV02.isPresent() || "true".equals(notifyCandidateUsersV02.get()))) {
this.notifyCandidateUsers(delegateTask);
}

val notifyCandidateGroups = NOTIFICATION_SEND_CANDIDATE_GROUPS.from(delegateTask).getOptional();
val notifyCandidateGroupsV02 = ProcessTaskConstants.APP_NOTIFICATION_SEND_CANDIDATE_GROUPS.from(delegateTask).getOptional();
if ((!notifyCandidateGroups.isPresent() || "true".equals(notifyCandidateGroups.get()))
&& (!notifyCandidateGroupsV02.isPresent() || "true".equals(notifyCandidateGroupsV02.get()))) {
this.notifyCandidateGroups(delegateTask);
}
}
// send notification on task assignment for assignee
// assignment event is used for direct user assignment
// update event is used for group task assignment
else if (delegateTask.getEventName().equals("assignment")) {
log.debug("Notification for created task: {}", delegateTask.getName());
val notify = NOTIFICATION_SEND.from(delegateTask).getOptional();
if (notify.isPresent()) {
Expand All @@ -98,6 +79,20 @@ else if (delegateTask.getEventName().equals("assignment")) {
&& (!notifyAssigneeV02.isPresent() || "true".equals(notifyAssigneeV02.get()))) {
this.notifyAssignee(delegateTask);
}

val notifyCandidateUsers = NOTIFICATION_SEND_CANDIDATE_USERS.from(delegateTask).getOptional();
val notifyCandidateUsersV02 = ProcessTaskConstants.APP_NOTIFICATION_SEND_CANDIDATE_USERS.from(delegateTask).getOptional();
if ((!notifyCandidateUsers.isPresent() || "true".equals(notifyCandidateUsers.get()))
&& (!notifyCandidateUsersV02.isPresent() || "true".equals(notifyCandidateUsersV02.get()))) {
this.notifyCandidateUsers(delegateTask);
}

val notifyCandidateGroups = NOTIFICATION_SEND_CANDIDATE_GROUPS.from(delegateTask).getOptional();
val notifyCandidateGroupsV02 = ProcessTaskConstants.APP_NOTIFICATION_SEND_CANDIDATE_GROUPS.from(delegateTask).getOptional();
if ((!notifyCandidateGroups.isPresent() || "true".equals(notifyCandidateGroups.get()))
&& (!notifyCandidateGroupsV02.isPresent() || "true".equals(notifyCandidateGroupsV02.get()))) {
this.notifyCandidateGroups(delegateTask);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void testDelegateTask_WithAssignee() throws Exception {
"digitalwf_notification_send_candidate_users", "false",
"digitalwf_notification_send_candidate_groups", "false",
"app_task_assignee", this.user.getLhmObjectId()
), "assignment");
), "create");
when(task.getCandidates()).thenReturn(Collections.<IdentityLink>emptySet());

final Mail mail = this.notifyUsers(task, this.userTaskDefaultMailContent, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void testDelegateTask_WithNotificationOff() throws Exception {
"app_notification_send_candidate_users", "false",
"app_notification_send_candidate_groups", "false",
"app_task_assignee", this.user.getLhmObjectId()
), "assignment");
), "create");
this.notifyUsers(task, null, 0);
}

Expand All @@ -79,7 +79,7 @@ void testDelegateTask_WithAssignee() throws Exception {
"app_notification_send_candidate_users", "false",
"app_notification_send_candidate_groups", "false",
"app_task_assignee", this.user.getLhmObjectId()
), "assignment");
), "create");
when(task.getCandidates()).thenReturn(Collections.<IdentityLink>emptySet());

final Mail mail = this.notifyUsers(task, this.userTaskDefaultMailContent, 1);
Expand Down Expand Up @@ -129,7 +129,7 @@ void testDelegateTask_WithCustomMailContentForUserTaskNotifications() throws Exc
"mail_body", "Email Body",
"mail_bottom_text", "Some Bottom Text",
"mail_subject", "Email Subject"
), "assignment");
), "create");
when(task.getCandidates()).thenReturn(Collections.<IdentityLink>emptySet());
final Map<String, String> customMailContent = Map.of(
"%%body_top%%", "Email Body",
Expand Down

0 comments on commit 3a4a499

Please sign in to comment.