@@ -32,8 +32,10 @@ const alertsClient = singleton(
3232) ;
3333
3434function buildTransportOptions ( alerts ?: boolean ) : MailTransportOptions {
35- const transportType = alerts ? env . ALERT_EMAIL_TRANSPORT : env . EMAIL_TRANSPORT
36- logger . debug ( `Constructing email transport '${ transportType } ' for usage '${ alerts ?'alerts' :'general' } '` )
35+ const transportType = alerts ? env . ALERT_EMAIL_TRANSPORT : env . EMAIL_TRANSPORT ;
36+ logger . debug (
37+ `Constructing email transport '${ transportType } ' for usage '${ alerts ? "alerts" : "general" } '`
38+ ) ;
3739
3840 switch ( transportType ) {
3941 case "aws-ses" :
@@ -43,8 +45,8 @@ function buildTransportOptions(alerts?: boolean): MailTransportOptions {
4345 type : "resend" ,
4446 config : {
4547 apiKey : alerts ? env . ALERT_RESEND_API_KEY : env . RESEND_API_KEY ,
46- }
47- }
48+ } ,
49+ } ;
4850 case "smtp" :
4951 return {
5052 type : "smtp" ,
@@ -54,9 +56,9 @@ function buildTransportOptions(alerts?: boolean): MailTransportOptions {
5456 secure : alerts ? env . ALERT_SMTP_SECURE : env . SMTP_SECURE ,
5557 auth : {
5658 user : alerts ? env . ALERT_SMTP_USER : env . SMTP_USER ,
57- pass : alerts ? env . ALERT_SMTP_PASSWORD : env . SMTP_PASSWORD
58- }
59- }
59+ pass : alerts ? env . ALERT_SMTP_PASSWORD : env . SMTP_PASSWORD ,
60+ } ,
61+ } ,
6062 } ;
6163 default :
6264 return { type : undefined } ;
@@ -87,21 +89,6 @@ export async function sendPlainTextEmail(options: SendPlainTextOptions) {
8789 return client . sendPlainText ( options ) ;
8890}
8991
90- export async function scheduleWelcomeEmail ( user : User ) {
91- //delay for one minute in development, longer in production
92- const delay = process . env . NODE_ENV === "development" ? 1000 * 60 : 1000 * 60 * 22 ;
93-
94- await workerQueue . enqueue (
95- "scheduleEmail" ,
96- {
97- email : "welcome" ,
98- to : user . email ,
99- name : user . name ?? undefined ,
100- } ,
101- { runAt : new Date ( Date . now ( ) + delay ) }
102- ) ;
103- }
104-
10592export async function scheduleEmail ( data : DeliverEmail , delay ?: { seconds : number } ) {
10693 const runAt = delay ? new Date ( Date . now ( ) + delay . seconds * 1000 ) : undefined ;
10794 await workerQueue . enqueue ( "scheduleEmail" , data , { runAt } ) ;
0 commit comments