-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse config and extrac fromEmailAddress from there
- Loading branch information
Showing
2 changed files
with
31 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { | |
SendEmailCommand, | ||
SendEmailCommandInput, | ||
} from '@aws-sdk/client-ses'; | ||
import * as t from 'io-ts'; | ||
|
||
const emailBody = (firstName: string) => ` | ||
<h4>Finalmente sei dei nostri</h4> | ||
|
@@ -42,11 +43,22 @@ const makeSesEmailParameters = ( | |
Source: from, | ||
}); | ||
|
||
export const SendEmailConfig = t.type({ | ||
fromEmailAddress: t.string, | ||
}); | ||
type SendEmailConfig = t.TypeOf<typeof SendEmailConfig>; | ||
|
||
export type SendEmailEnv = { | ||
readonly config: SendEmailConfig; | ||
readonly ses: SES; | ||
}; | ||
|
||
export const makeHandler = | ||
(ses: SES) => async (event: PostConfirmationConfirmSignUpTriggerEvent) => { | ||
({ ses, config }: SendEmailEnv) => | ||
async (event: PostConfirmationConfirmSignUpTriggerEvent) => { | ||
const { email, given_name } = event.request.userAttributes; | ||
if (email) { | ||
const fromEmail = 'Developer Portal <[email protected]>'; // FIXME | ||
const fromEmail = config.fromEmailAddress; | ||
const subject = 'Il tuo account è attivo'; | ||
const params = makeSesEmailParameters( | ||
email, | ||
|