-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from ReflectionsProjections/dev/alex/ses
- Loading branch information
Showing
5 changed files
with
817 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ import dotenv from "dotenv"; | |
import { z } from "zod"; | ||
import { getEnv } from "./utilities"; | ||
|
||
import AWS from "aws-sdk"; | ||
|
||
dotenv.config(); | ||
|
||
export const Environment = z.enum(["PRODUCTION", "DEVELOPMENT", "TESTING"]); | ||
|
@@ -79,6 +81,8 @@ export const Config = { | |
// QR Scanning | ||
QR_HASH_ITERATIONS: 10000, | ||
QR_HASH_SECRET: getEnv("QR_HASH_SECRET"), | ||
|
||
OUTGOING_EMAIL_ADDRESSES: z.enum(["[email protected]"]), | ||
}; | ||
|
||
export const DeviceRedirects: Record<string, string> = { | ||
|
@@ -87,4 +91,8 @@ export const DeviceRedirects: Record<string, string> = { | |
mobile: "exp://192.168.86.24:8081/--/Main", | ||
}; | ||
|
||
export const ses = new AWS.SES({ | ||
region: Config.S3_REGION, | ||
}); | ||
|
||
export default Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ses, Config } from "../../config"; | ||
|
||
export function sendManyEmails( | ||
emailIds: string[], | ||
subject: string, | ||
emailBody: string | ||
): Promise<AWS.SES.SendEmailResponse>[] { | ||
const emailPromises: Promise<AWS.SES.SendEmailResponse>[] = []; | ||
for (let i = 0; i < emailIds.length; i++) { | ||
emailPromises.push(sendEmail(emailIds[i], subject, emailBody)); | ||
} | ||
return emailPromises; | ||
} | ||
|
||
export function sendEmail( | ||
emailId: string, | ||
subject: string, | ||
emailBody: string | ||
): Promise<AWS.SES.SendEmailResponse> { | ||
return ses | ||
.sendEmail({ | ||
Destination: { | ||
ToAddresses: [emailId], | ||
}, | ||
Message: { | ||
Body: { | ||
Text: { | ||
Data: emailBody, | ||
}, | ||
}, | ||
Subject: { | ||
Data: subject, | ||
}, | ||
}, | ||
Source: Config.OUTGOING_EMAIL_ADDRESSES.Enum[ | ||
"[email protected]" | ||
], | ||
}) | ||
.promise(); | ||
} |
Oops, something went wrong.