From a8625fcdc18f5c5079849f66d0543d5d6041e0c2 Mon Sep 17 00:00:00 2001 From: Graham Lee Date: Tue, 14 Jun 2022 15:23:53 +0100 Subject: [PATCH] Look up welcome email text by disease #2712 --- .../api/src/controllers/auth.ts | 16 ++-------- .../curator-service/api/src/util/base-url.ts | 12 ------- .../api/src/util/instance-details.ts | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 26 deletions(-) delete mode 100644 verification/curator-service/api/src/util/base-url.ts create mode 100644 verification/curator-service/api/src/util/instance-details.ts diff --git a/verification/curator-service/api/src/controllers/auth.ts b/verification/curator-service/api/src/controllers/auth.ts index 3962e6c37..b3a6e82ec 100644 --- a/verification/curator-service/api/src/controllers/auth.ts +++ b/verification/curator-service/api/src/controllers/auth.ts @@ -22,7 +22,7 @@ import bcrypt from 'bcrypt'; import * as crypto from 'crypto'; import EmailClient from '../clients/email-client'; import { ObjectId } from 'mongodb'; -import { baseURL } from '../util/base-url'; +import { baseURL, welcomeEmail } from '../util/instance-details'; // Global variable for newsletter acceptance let isNewsletterAccepted: boolean; @@ -688,19 +688,7 @@ export class AuthController { await this.emailClient.send( [email], 'Welcome to Global.health', - `

Hello ${email},

-

Thank you for registering with Global.health! We're thrilled to have you join our international community and mission to advance the global response to infectious diseases through the sharing of trusted and open public health data.

-

Here are a few things you can do:

- -

If you have any questions, suggestions, or connections don't hesitate to email us and a member of our team will be sure to follow up.

-

Thank you again for your interest and support! We hope G.h proves valuable to your work and look forward to hearing from you.

-

The G.h Team

`, + welcomeEmail(this.disease, email), ); return done(null, userPublicFields(newUser)); diff --git a/verification/curator-service/api/src/util/base-url.ts b/verification/curator-service/api/src/util/base-url.ts deleted file mode 100644 index 47c1742d4..000000000 --- a/verification/curator-service/api/src/util/base-url.ts +++ /dev/null @@ -1,12 +0,0 @@ -const urlMap: { [idx: string]: { [idx: string]: string } } = { - 'covid-19': { - local: 'http://localhost:3002', - dev: 'https://dev-data.covid-19.global.health', - qa: 'https://qa-data.covid-19.global.health', - prod: 'https://data.covid-19.global.health', - }, -}; - -export function baseURL(disease: string, environment: string): string { - return urlMap[disease]?.[environment] ?? 'http://localhost:3002'; -} diff --git a/verification/curator-service/api/src/util/instance-details.ts b/verification/curator-service/api/src/util/instance-details.ts new file mode 100644 index 000000000..6110af9a2 --- /dev/null +++ b/verification/curator-service/api/src/util/instance-details.ts @@ -0,0 +1,32 @@ +const urlMap: { [idx: string]: { [idx: string]: string } } = { + 'covid-19': { + local: 'http://localhost:3002', + dev: 'https://dev-data.covid-19.global.health', + qa: 'https://qa-data.covid-19.global.health', + prod: 'https://data.covid-19.global.health', + }, +}; + +export function baseURL(disease: string, environment: string): string { + return urlMap[disease]?.[environment] ?? 'http://localhost:3002'; +} + +const welcomeMessages: { [idx: string]: string } = { + 'covid-19': `

Thank you for registering with Global.health! We're thrilled to have you join our international community and mission to advance the global response to infectious diseases through the sharing of trusted and open public health data.

+

Here are a few things you can do:

+ +

If you have any questions, suggestions, or connections don't hesitate to email us and a member of our team will be sure to follow up.

+

Thank you again for your interest and support! We hope G.h proves valuable to your work and look forward to hearing from you.

+

The G.h Team

`, +}; + +export function welcomeEmail(disease: string, email: string): string { + const message = welcomeMessages[disease] ?? ''; + return `

Hello ${email},

\n${message}`; +}