diff --git a/server/src/core/app.ts b/server/src/core/app.ts index 92992023..ad605921 100644 --- a/server/src/core/app.ts +++ b/server/src/core/app.ts @@ -108,7 +108,7 @@ export interface AppConfig { */ googleClientId: string; sendgridApiKey: string; - socialReliefEmail: string; + emailSender: string; }; export function loadAppConfigFromEnv(env: { [key: string]: string }): AppConfig { @@ -137,6 +137,6 @@ export function loadAppConfigFromEnv(env: { [key: string]: string }): AppConfig statsComputationInterval: (env.STATS_COMPUTATION_INTERVAL && Number(env.STATS_COMPUTATION_INTERVAL)) || 1, googleClientId: env.GOOGLE_CLIENT_ID, sendgridApiKey: env.SENDGRID_API_KEY || '', - socialReliefEmail: env.SOCIAL_RELIEF_EMAIL || 'socialrelief@manuscript.live' + emailSender: env.EMAIL_SENDER || 's' }; } \ No newline at end of file diff --git a/server/src/core/bootstrap.ts b/server/src/core/bootstrap.ts index d6e1bf3f..7d774380 100644 --- a/server/src/core/bootstrap.ts +++ b/server/src/core/bootstrap.ts @@ -6,7 +6,7 @@ import { createDbConnectionFailedError } from './error'; import { DonationDistributions } from './distribution'; import { SystemLocks } from './system-lock'; import { AtSmsProvider } from './sms'; -import { sendgridEmailProvider } from './email'; +import { SendGridEmailProvider } from './email'; import { Invitations } from './invitation'; import { EventBus } from './event'; import { UserNotifications } from './user-notification'; @@ -62,9 +62,9 @@ export async function bootstrap(config: AppConfig): Promise { apiKey: config.atApiKey, sender: config.atSmsSender }); - const emailProvider = new sendgridEmailProvider({ + const emailProvider = new SendGridEmailProvider({ apiKey: config.sendgridApiKey, - socialReliefEmail: config.socialReliefEmail + emailSender: config.emailSender }); // starts listening to events when instantiated diff --git a/server/src/core/email/index.ts b/server/src/core/email/index.ts index 1e769839..dfad3e9e 100644 --- a/server/src/core/email/index.ts +++ b/server/src/core/email/index.ts @@ -1,2 +1,2 @@ export * from './types'; -export { sendgridEmailProvider } from './sendgrid-email-provider'; \ No newline at end of file +export { SendGridEmailProvider } from './sendgrid-email-provider'; \ No newline at end of file diff --git a/server/src/core/email/sendgrid-email-provider.ts b/server/src/core/email/sendgrid-email-provider.ts index ee00b10f..b0ef0a45 100644 --- a/server/src/core/email/sendgrid-email-provider.ts +++ b/server/src/core/email/sendgrid-email-provider.ts @@ -2,24 +2,24 @@ import { EmailProvider } from './types'; import { rethrowIfAppError, createEmailDeliveryFailedError, createSendGridApiError } from '../error'; import sgMail = require('@sendgrid/mail'); -export interface sendgridEmailProviderArgs { +export interface SendGridEmailProviderArgs { apiKey: string, - socialReliefEmail: string + emailSender: string }; -export class sendgridEmailProvider implements EmailProvider{ - private socialReliefEmail: string; +export class SendGridEmailProvider implements EmailProvider{ + private emailSender: string; - constructor(args: sendgridEmailProviderArgs) { + constructor(args: SendGridEmailProviderArgs) { sgMail.setApiKey(args.apiKey); - this.socialReliefEmail = args.socialReliefEmail; + this.emailSender = args.emailSender; } async sendEmail(to: string, message: string): Promise { try { const res = await sgMail.send({ to, - from: this.socialReliefEmail, + from: this.emailSender, subject: 'Social Relief Notification', text: message, });