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:
parent
7f32fde707
commit
06c733bb0b
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user