Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating lambda to send registration email to ala support and second … #16

Merged
merged 3 commits into from
Feb 2, 2023
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
4 changes: 2 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ VITE_OIDC_LOGOUT_REDIRECT_URI=https://${SUB_DOMAIN}.${HOSTED_ZONE}/logout
VITE_TOKENS_API=https://apis.ala.org.au/tokens
# lambda
LAMBDA_CALLER=arn:aws:execute-api:ap-southeast-2:736913556139:3uurj4p257/*/POST/register
SOURCE_EMAIL=support@ala.org.au
SOURCE_EMAIL=info@ala.org.au
DEST_EMAIL=support@ala.org.au


Expand All @@ -128,5 +128,5 @@ VITE_OIDC_LOGOUT_REDIRECT_URI=https://${SUB_DOMAIN}.${HOSTED_ZONE}/logout
VITE_TOKENS_API=https://apis.ala.org.au/tokens
# lambda
LAMBDA_CALLER=arn:aws:execute-api:ap-southeast-2:736913556139:3uurj4p257/*/POST/register
SOURCE_EMAIL=support@ala.org.au
SOURCE_EMAIL=info@ala.org.au
DEST_EMAIL=support@ala.org.au
56 changes: 44 additions & 12 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 All @@ -39,33 +39,65 @@ exports.handler = async (event, context) => {
</li>
</ul>

<p>Regards,</br>
ALA Systems Team
</p>
<br>
<p>Regards,</p>
<p>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</p>

<p>We'd like to let you know that your 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 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.

<br>
<p>Regards,</p>
<p>ALA Systems Team</p>
<p><a>href="https://ala.org.au">ala.org.au</a></p>

<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