Skip to content

Commit

Permalink
Downstream: mail provider debug values
Browse files Browse the repository at this point in the history
Updates configuration to allow for indication of when a production
run is being performed in an environment, and refactors the layering
of those config values.

Also minor updates to package dependencies.
  • Loading branch information
jeffwilcox committed Mar 17, 2023
1 parent f5f8e39 commit 02b4d88
Show file tree
Hide file tree
Showing 8 changed files with 1,266 additions and 1,350 deletions.
18 changes: 18 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"enableGlobDot": true,
"useGitignore": true,
"words": [
"aadgraph",
"aadid",
"aadname",
"aadoid",
Expand Down Expand Up @@ -114,6 +115,7 @@
"cloudmine",
"CloudMine",
"clsdir",
"clust",
"cnames",
"CNTK",
"codeofconductcoursecompleted",
Expand Down Expand Up @@ -165,7 +167,9 @@
"datamonth",
"datamonthiso",
"datasharing",
"datatable",
"DATETIME",
"dcount",
"dbaeumer",
"decisionmaker",
"Decisionmaker",
Expand Down Expand Up @@ -271,6 +275,7 @@
"ghid",
"GHID",
"ghname",
"ghowners",
"GHPI",
"ghpimigrationphase",
"ghrp",
Expand All @@ -294,6 +299,7 @@
"godo",
"goodfirstissue",
"grantedtime",
"graphviz",
"hackathon",
"hackathons",
"hardlimit",
Expand Down Expand Up @@ -360,6 +366,7 @@
"labelloc",
"languagesspoken",
"latrop",
"leftouter",
"legalcontact",
"legalentities",
"lightup",
Expand All @@ -382,6 +389,7 @@
"lowercaser",
"luxon",
"maillist",
"mailout",
"mailwithsemicolon",
"maint",
"maintainercorporateids",
Expand All @@ -397,6 +405,7 @@
"managerid",
"managerunlink",
"Markdownlint",
"MCAPS",
"MEMBERTOMAINTAINER",
"memex",
"mergedpullscount",
Expand Down Expand Up @@ -476,6 +485,7 @@
"opensource",
"OPENSOURCE",
"opensourcecontributions",
"opensourcedirectowners",
"opensourcedocs",
"opensourcedocsprod",
"opensourceprod",
Expand Down Expand Up @@ -646,6 +656,7 @@
"Satya",
"scansummary",
"scorecardreprocessrequest",
"SCIM",
"secretscanningonpush",
"secscandata",
"securitygroupalias",
Expand Down Expand Up @@ -694,6 +705,7 @@
"SSIRP",
"sslify",
"Sslify",
"standardsredirect",
"stargazerscount",
"startclean",
"StartClean",
Expand Down Expand Up @@ -728,19 +740,24 @@
"thirdpartytype",
"thirdpartyusername",
"thirtypercent",
"threatmodel",
"tickettype",
"timeago",
"timebound",
"timeframe",
"timezonename",
"timezoneoffset",
"tlink",
"tolower",
"totalcount",
"toupper",
"touchedtime",
"treatedconsent",
"treateddirectmanager",
"Treateds",
"tsbuild",
"Tpng",
"Tsvg",
"twentypercent",
"typeahead",
"typeaheadjs",
Expand Down Expand Up @@ -807,6 +824,7 @@
"workboarding",
"xamarinhq",
"Xcache",
"xlink",
"XSTORE",
"xtable",
"yamls"
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dist

# View
views/email/email.css

.environment/copilot/
4 changes: 3 additions & 1 deletion business/operations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,9 @@ export class Operations
return repository;
}
} catch (err) {
console.error(err);
if (!ErrorHelper.IsNotFound(err)) {
console.error(err);
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion config/mail.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"provider": "env://MAIL_PROVIDER",
"from": "env://MAIL_FROM",
"overrideRecipient": "env://MAIL_OVERRIDE_RECIPIENT",
"debug": {
"overrideRecipient": "env://MAIL_OVERRIDE_RECIPIENT",
"isProductionRun": "env://EMAIL_PRODUCTION_RUN?trueIf=1",
"testTargetCorporateId": "env://TARGET_CORPORATE_ID"
},
"customService": {
"url": "env://MAIL_CUSTOMSERVICE_URL",
"apiKey": "env://MAIL_CUSTOMSERVICE_KEY",
Expand Down
7 changes: 6 additions & 1 deletion config/mail.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export type ConfigRootMail = {
export type ConfigMail = {
provider: string;
from: string;
overrideRecipient: string;

debug: {
overrideRecipient: string;
isProductionRun: boolean;
testTargetCorporateId: string;
};

customService: {
url: string;
Expand Down
12 changes: 6 additions & 6 deletions lib/mailProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface IMailProvider {
}

export function isOverridingRecipients(config: SiteConfiguration) {
return !!config.mail.overrideRecipient;
return !!config.mail.debug.overrideRecipient;
}

function patchOverride(provider, newToAddress, htmlOrNot) {
Expand Down Expand Up @@ -74,15 +74,15 @@ function patchOverride(provider, newToAddress, htmlOrNot) {
return provider;
}

export function createMailProviderInstance(config): IMailProvider {
export function createMailProviderInstance(config: SiteConfiguration): IMailProvider {
const deployment = getCompanySpecificDeployment();
let mailProvider: IMailProvider = null;
const mailConfig = config.mail;
if (deployment?.features?.mailProvider?.tryCreateInstance) {
mailProvider = deployment.features.mailProvider.tryCreateInstance(config);
if (mailProvider) {
if (mailConfig.overrideRecipient) {
patchOverride(mailProvider, mailConfig.overrideRecipient, mailProvider.html);
if (mailConfig.debug.overrideRecipient) {
patchOverride(mailProvider, mailConfig.debug.overrideRecipient, mailProvider.html);
}
return mailProvider;
}
Expand All @@ -109,8 +109,8 @@ export function createMailProviderInstance(config): IMailProvider {
);
}
}
if (mailConfig.overrideRecipient) {
patchOverride(mailProvider, mailConfig.overrideRecipient, mailProvider.html);
if (mailConfig.debug.overrideRecipient) {
patchOverride(mailProvider, mailConfig.debug.overrideRecipient, mailProvider.html);
}
return mailProvider;
}
Loading

0 comments on commit 02b4d88

Please sign in to comment.