Skip to content

Commit

Permalink
updating lambda to send registration email to ala support and second …
Browse files Browse the repository at this point in the history
…email from ala support to user - to prevent to and from adresses from being the same
  • Loading branch information
sughics committed Feb 2, 2023
1 parent 1d62e3b commit 3bff939
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions src/lambda/register_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.handler = async (event, context) => {
}


const body = `
const registrationBody = `
<h4>ATTN: ALA Support </br>This is a user generated request from the Atlas of Living Australia's (ALA) Tokens Application</h4>
<p>Please find the Client application registration details below: </p>
Expand Down Expand Up @@ -42,30 +42,62 @@ exports.handler = async (event, context) => {
<p>Regards,</br>
ALA Systems Team
</p>
`


const confirmationBody = `
<p>Dear User, </p>
<p>This is an auto-generated response from the Atlas of Living Australia's (ALA) Tokens Application</h4></p>
<p>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.</p>
<p>Regards,</br>
ALA Systems Team
</br>
<a href="https://ala.org.au">ala.org.au</a>
</p>
<p style="font-size: small">This email address <strong>(${event.resourceOwnerEmail}) </strong> included in the CC was provided to us via the ALA Tokens App at <a href="https://tokens.ala.org.au">tokens.ala.org.au</a>. If you <strong>did not</strong> submit a request in relation to API access, please email us at support@ala.org.au as soon as possible.
<p style="font-size: small">This email address <strong>(${event.resourceOwnerEmail}) </strong> was provided to us via the ALA Tokens App at <a href="https://tokens.ala.org.au">tokens.ala.org.au</a>. If you <strong>did not</strong> submit a request in relation to API access, please email us at support@ala.org.au as soon as possible.
</p>
`
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!"
Expand Down

0 comments on commit 3bff939

Please sign in to comment.