Skip to content

Commit

Permalink
Send notification on self-approval
Browse files Browse the repository at this point in the history
  • Loading branch information
jpassing committed Nov 28, 2023
1 parent b7f0338 commit 6d5725f
Showing 1 changed file with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ public ActivationStatusResponse selfApproveActivation(
activations.add(activation);

for (var service : this.notificationServices) {
//TODO: send notification
service.sendNotification(new ActivationSelfApprovedNotification(
activation,
iapPrincipal.getId(),
request.justification));
}

this.logAdapter
Expand Down Expand Up @@ -876,7 +879,8 @@ private ActivationStatus(RoleActivationService.Activation activation) {
// -------------------------------------------------------------------------

/**
* Email to reviewers, requesting their approval.
* Notification indicating that a multi-party approval request has been made
* and is pending approval.
*/
public class RequestActivationNotification extends NotificationService.Notification
{
Expand Down Expand Up @@ -912,7 +916,7 @@ public String getType() {
}

/**
* Email to the beneficiary, confirming an approval.
* Notification indicating that a multi-party approval was granted.
*/
public class ActivationApprovedNotification extends NotificationService.Notification {
protected ActivationApprovedNotification(
Expand Down Expand Up @@ -950,6 +954,42 @@ public String getType() {
}
}

/**
* Notification indicating that a self-approval was performed.
*/
public class ActivationSelfApprovedNotification extends NotificationService.Notification {
protected ActivationSelfApprovedNotification(
RoleActivationService.Activation activation,
UserId beneficiary,
String justification)
{
super(
List.of(beneficiary),
List.of(),
String.format(
"Activated role '%s' on '%s'",
activation.projectRole.roleBinding,
activation.projectRole.getProjectId()));

this.properties.put("BENEFICIARY", beneficiary);
this.properties.put("PROJECT_ID", activation.projectRole.getProjectId());
this.properties.put("ROLE", activation.projectRole.roleBinding.role);
this.properties.put("START_TIME", activation.startTime);
this.properties.put("END_TIME", activation.endTime);
this.properties.put("JUSTIFICATION", justification);
}

@Override
protected boolean isReply() {
return true;
}

@Override
public String getType() {
return "ActivationSelfApproved";
}
}

// -------------------------------------------------------------------------
// Options.
// -------------------------------------------------------------------------
Expand Down

0 comments on commit 6d5725f

Please sign in to comment.