Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BambanzaJuniorThe2nd committed Aug 28, 2020
1 parent 7da684e commit 8069ad0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions server/src/core/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface AppConfig {
*/
googleClientId: string;
sendgridApiKey: string;
socialReliefEmail: string;
emailSender: string;
};

export function loadAppConfigFromEnv(env: { [key: string]: string }): AppConfig {
Expand Down Expand Up @@ -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 || '[email protected]'
emailSender: env.EMAIL_SENDER || 's'
};
}
6 changes: 3 additions & 3 deletions server/src/core/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,9 +62,9 @@ export async function bootstrap(config: AppConfig): Promise<App> {
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
Expand Down
2 changes: 1 addition & 1 deletion server/src/core/email/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './types';
export { sendgridEmailProvider } from './sendgrid-email-provider';
export { SendGridEmailProvider } from './sendgrid-email-provider';
14 changes: 7 additions & 7 deletions server/src/core/email/sendgrid-email-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
try {
const res = await sgMail.send({
to,
from: this.socialReliefEmail,
from: this.emailSender,
subject: 'Social Relief Notification',
text: message,
});
Expand Down

0 comments on commit 8069ad0

Please sign in to comment.