Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ResponseEntity<InlineResponse200> execute(
// email faster
// It must only be sent once AWS Batch has accepted the job and returned
// a job id, otherwise we promise the user a file that will never be produced.
restServices.notifyUser(recipient, uuid, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation);
restServices.notifyUser(recipient, uuid, key, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation, outputFormat);

var value = new InlineValue(response.getBody());
var status = new InlineValue(Integer.toString(HttpStatus.OK.value()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ public RestServices(BatchClient batchClient, ObjectMapper objectMapper, String b
this.batchJobQueue = batchJobQueue;
}

public void notifyUser(String recipient, String uuid, String startDate, String endDate, Object multiPolygon, String collectionTitle,
public void notifyUser(String recipient, String uuid, String key, String startDate, String endDate, Object multiPolygon, String collectionTitle,
String fullMetadataLink,
String suggestedCitation) {
String suggestedCitation,
String outputFormat) {

String aodnInfoSender = "no.reply@aodn.org.au";

try (SesClient ses = SesClient.builder().build()) {
var subject = Content.builder().data("Start processing data file whose uuid is: " + uuid).build();
var content = Content.builder().data(generateStartedEmailContent(uuid, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation)).build();
var content = Content.builder().data(generateStartedEmailContent(uuid, key, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation, outputFormat)).build();
var destination = Destination.builder().toAddresses(recipient).build();

var body = Body.builder().html(content).build();
Expand Down Expand Up @@ -148,14 +149,17 @@ private String submitJob(String jobName, String jobQueue, String jobDefinition,
return jobId;
}

private String generateStartedEmailContent(
// package-private so JobStartedEmailPreview (test scope) can render it
String generateStartedEmailContent(
String uuid,
String key,
String startDate,
String endDate,
Object multipolygon,
String collectionTitle,
String fullMetadataLink,
String suggestedCitation
String suggestedCitation,
String outputFormat
) {
try (InputStream inputStream = getClass().getResourceAsStream("/job-started-email.html")) {

Expand All @@ -174,10 +178,16 @@ private String generateStartedEmailContent(
objectMapper
);

// Keys arrive comma-separated; show one per line. Absent means "all files".
String keysDisplay = (key != null && !key.isBlank()) ? key.replace(",", "<br>") : "*";

// Replace all variables in one chain
return template
.replace("{{HEADER_IMG}}", EmailUtils.readBase64Image("header.txt"))
.replace("{{collectionTitle}}", collectionTitle != null ? collectionTitle : "")
.replace("{{uuid}}", uuid != null ? uuid : "")
.replace("{{keys}}", keysDisplay)
.replace("{{outputFormat}}", outputFormat != null ? outputFormat.toUpperCase() : "")
.replace("{{subsettingSection}}", subsettingSection)
.replace("{{BBOX_IMG}}", EmailUtils.readBase64Image("bbox.txt"))
.replace("{{POLYGON_IMG}}", EmailUtils.readBase64Image("polygon.txt"))
Expand Down
Loading
Loading