From 06c733bb0b9c2cc5b26fb51f594a07487bec612f Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 5 May 2022 11:15:54 +0800 Subject: [PATCH] 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 --- .../lib/api-version-compatibility-service.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ghost/api-version-compatibility-service/lib/api-version-compatibility-service.js b/ghost/api-version-compatibility-service/lib/api-version-compatibility-service.js index e15ab69c3a..757fedde2e 100644 --- a/ghost/api-version-compatibility-service/lib/api-version-compatibility-service.js +++ b/ghost/api-version-compatibility-service/lib/api-version-compatibility-service.js @@ -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} options.sendEmail - email sending function * @param {() => Promise} options.fetchEmailsToNotify - email address to receive notifications * @param {(acceptVersion: String) => Promise} options.fetchHandled - retrives already handled compatibility notifications * @param {(acceptVersion: String) => Promise} 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 }); }