mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Made integration naming less technical
refs https://github.com/TryGhost/Toolbox/issues/292 - The audience of the notification emails for version missmatch could be less technical - site owneres are usually creators not programmers. Not using complex technical details in the email subject/body should make the incompatibility more approachable to deal with.
This commit is contained in:
parent
d7768efb40
commit
ff4bdb5ff8
@ -16,15 +16,16 @@ class APIVersionCompatibilityService {
|
||||
|
||||
async handleMismatch({acceptVersion, contentVersion, userAgent = ''}) {
|
||||
if (!await this.fetchHandled(acceptVersion)) {
|
||||
const trimmedUseAgent = userAgent.split('/')[0];
|
||||
const emailTemplate = `
|
||||
${userAgent} integration expected Ghost version: ${acceptVersion}
|
||||
${trimmedUseAgent} integration expected Ghost version: ${acceptVersion}
|
||||
Current Ghost version: ${contentVersion}
|
||||
`;
|
||||
|
||||
const emails = await this.fetchEmailsToNotify();
|
||||
for (const email of emails) {
|
||||
await this.sendEmail({
|
||||
subject: `Attention required: Your ${userAgent} integration has failed`,
|
||||
subject: `Attention required: Your ${trimmedUseAgent} integration has failed`,
|
||||
to: email,
|
||||
html: emailTemplate
|
||||
});
|
||||
|
@ -113,4 +113,29 @@ describe('APIVersionCompatibilityService', function () {
|
||||
assert.match(sendEmail.args[2][0].html, /Elaborate Fox integration expected Ghost version: v4.8/);
|
||||
assert.match(sendEmail.args[2][0].html, /Current Ghost version: v5.1/);
|
||||
});
|
||||
|
||||
it('Trims down the name of the integration when a lot of meta information is present in user-agent header', async function (){
|
||||
const sendEmail = sinon.spy();
|
||||
const fetchHandled = sinon.spy();
|
||||
const saveHandled = sinon.spy();
|
||||
|
||||
const compatibilityService = new APIVersionCompatibilityService({
|
||||
sendEmail,
|
||||
fetchEmailsToNotify: async () => ['test_env@example.com'],
|
||||
fetchHandled,
|
||||
saveHandled
|
||||
});
|
||||
|
||||
await compatibilityService.handleMismatch({
|
||||
acceptVersion: 'v4.5',
|
||||
contentVersion: 'v5.1',
|
||||
userAgent: 'Zapier/2.3 GhostAdminSDK/2.4.0'
|
||||
});
|
||||
|
||||
assert.equal(sendEmail.called, true);
|
||||
assert.equal(sendEmail.args[0][0].to, 'test_env@example.com');
|
||||
assert.equal(sendEmail.args[0][0].subject, `Attention required: Your Zapier integration has failed`);
|
||||
assert.match(sendEmail.args[0][0].html, /Zapier integration expected Ghost version: v4.5/);
|
||||
assert.match(sendEmail.args[0][0].html, /Current Ghost version: v5.1/);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user