2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Added explicit "text" parameter in sendEmail call

refs https://github.com/TryGhost/Toolbox/issues/292

- This is groundwork before adding separate html/text generation. Should make future additions more readable
This commit is contained in:
Naz 2022-05-05 11:15:54 +08:00
parent 7f32fde707
commit 06c733bb0b

View file

@ -2,7 +2,7 @@ class APIVersionCompatibilityService {
/**
*
* @param {Object} options
* @param {Function} options.sendEmail - email sending function
* @param {(Object: {subject: String, to: String, text: String, html: String}) => Promise<any>} options.sendEmail - email sending function
* @param {() => Promise<any>} options.fetchEmailsToNotify - email address to receive notifications
* @param {(acceptVersion: String) => Promise<any>} options.fetchHandled - retrives already handled compatibility notifications
* @param {(acceptVersion: String) => Promise<any>} options.saveHandled - persists already handled compatibility notifications
@ -17,17 +17,19 @@ class APIVersionCompatibilityService {
async handleMismatch({acceptVersion, contentVersion, userAgent = ''}) {
if (!await this.fetchHandled(acceptVersion)) {
const trimmedUseAgent = userAgent.split('/')[0];
const emailTemplate = `
const htmlContent = `
${trimmedUseAgent} integration expected Ghost version: ${acceptVersion}
Current Ghost version: ${contentVersion}
`;
const textContent = htmlContent;
const emails = await this.fetchEmailsToNotify();
for (const email of emails) {
await this.sendEmail({
subject: `Attention required: Your ${trimmedUseAgent} integration has failed`,
to: email,
html: emailTemplate
html: htmlContent,
text: textContent
});
}