From 3bff939cf03098df1ecc356d6b0ab7198adca438 Mon Sep 17 00:00:00 2001 From: Sushant <105408469+sughics@users.noreply.github.com> Date: Thu, 2 Feb 2023 16:44:39 +1100 Subject: [PATCH] updating lambda to send registration email to ala support and second email from ala support to user - to prevent to and from adresses from being the same --- src/lambda/register_client.js | 50 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/src/lambda/register_client.js b/src/lambda/register_client.js index 70c3ce7..e97ab93 100644 --- a/src/lambda/register_client.js +++ b/src/lambda/register_client.js @@ -14,7 +14,7 @@ exports.handler = async (event, context) => { } - const body = ` + const registrationBody = `

ATTN: ALA Support
This is a user generated request from the Atlas of Living Australia's (ALA) Tokens Application

Please find the Client application registration details below:

@@ -42,30 +42,62 @@ exports.handler = async (event, context) => {

Regards,
ALA Systems Team

+ ` + + + const confirmationBody = ` +

Dear User,

+ +

This is an auto-generated response from the Atlas of Living Australia's (ALA) Tokens Application

+ +

We'd like to let you know that you Client Application Registration request has been submitted to ALA. Our team will review your request and respond to you as soon as they can.

+ +

Regards,
+ ALA Systems Team +
+ ala.org.au +

-

This email address (${event.resourceOwnerEmail}) included in the CC was provided to us via the ALA Tokens App at tokens.ala.org.au. If you did not submit a request in relation to API access, please email us at support@ala.org.au as soon as possible. +

This email address (${event.resourceOwnerEmail}) was provided to us via the ALA Tokens App at tokens.ala.org.au. If you did not submit a request in relation to API access, please email us at support@ala.org.au as soon as possible.

- ` - const emailParams = { + + // send email from ALA SRC_EMAIL to ALA DEST_EMAIL - this should create a ticket in service desk + const registrationEmailParams = { Destination: { - ToAddresses: [DEST_EMAIL], - CcAddresses: [event.resourceOwnerEmail] + ToAddresses: [DEST_EMAIL] }, Message: { Body: { - Html: { Data: body} + Html: { Data: registrationBody} }, Subject: { Data: "Request for ALA Client Application Registration" }, }, Source: SOURCE_EMAIL, }; + + // send a confirmation email from from the public DEST_EMAIL to requesting user + const confirmationEmailParams = { + Destination: { + ToAddresses: [event.resourceOwnerEmail] + }, + Message: { + Body: { + Html: { Data: confirmationBody} + }, + + Subject: { Data: "Request for ALA Client Application Registration" }, + }, + Source: DEST_EMAIL, + }; try { - const command = new SendEmailCommand(emailParams) - await client.send(command) + const registrationCommand = new SendEmailCommand(registrationEmailParams) + const confirmationCommand = new SendEmailCommand(confirmationEmailParams) + await client.send(registrationCommand) + await client.send(confirmationCommand) return { statusCode: 200, body: "Request submitted successfully!"