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 3e62a436a2..045d470c9e 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 @@ -25,7 +25,15 @@ class APIVersionCompatibilityService { }); } - async handleMismatch({acceptVersion, contentVersion, userAgent = ''}) { + /** + * Version mismatch handler doing the logic of picking a template and sending a notification email + * @param {Object} options + * @param {string} options.acceptVersion - client's accept-version header value + * @param {string} options.contentVersion - server's content-version header value + * @param {string} options.requestURL - url that was requested and failed compatibility test + * @param {string} [options.userAgent] - client's user-agent header value + */ + async handleMismatch({acceptVersion, contentVersion, requestURL, userAgent = ''}) { if (!await this.fetchHandled(acceptVersion)) { const trimmedUseAgent = userAgent.split('/')[0]; const emails = await this.fetchEmailsToNotify(); @@ -45,7 +53,8 @@ class APIVersionCompatibilityService { acceptVersion, contentVersion, clientName: trimmedUseAgent, - recipientEmail: email + recipientEmail: email, + requestURL: requestURL } }); diff --git a/ghost/api-version-compatibility-service/lib/templates/generic-mismatch.html b/ghost/api-version-compatibility-service/lib/templates/generic-mismatch.html index dc92399c91..d252623df6 100644 --- a/ghost/api-version-compatibility-service/lib/templates/generic-mismatch.html +++ b/ghost/api-version-compatibility-service/lib/templates/generic-mismatch.html @@ -140,7 +140,7 @@ a {
Current Ghost version:  {{contentVersion}}
- Failed request URL:  /content/posts/1234/ + Failed request URL:  {{requestURL}}

diff --git a/ghost/api-version-compatibility-service/test/api-version-compatibility-service.test.js b/ghost/api-version-compatibility-service/test/api-version-compatibility-service.test.js index d515e827a8..41f17d47a1 100644 --- a/ghost/api-version-compatibility-service/test/api-version-compatibility-service.test.js +++ b/ghost/api-version-compatibility-service/test/api-version-compatibility-service.test.js @@ -27,7 +27,8 @@ describe('APIVersionCompatibilityService', function () { await compatibilityService.handleMismatch({ acceptVersion: 'v4.5', contentVersion: 'v5.1', - userAgent: 'Elaborate Fox' + userAgent: 'Elaborate Fox', + requestURL: 'https://amazeballsghostsite.com/ghost/api/admin/posts/dew023d9203se4' }); assert.equal(sendEmail.called, true); @@ -37,6 +38,7 @@ describe('APIVersionCompatibilityService', function () { assert.match(sendEmail.args[0][0].html, /Ghost has noticed that your Elaborate Fox<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[0][0].html, /Elaborate Fox integration expected Ghost version:<\/strong>  v4.5/); assert.match(sendEmail.args[0][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[0][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); assert.match(sendEmail.args[0][0].html, /This email was sent from Elaborate Fox<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[0][0].html, /Elaborate Fox integration expected Ghost version:<\/strong>  v4.5/); assert.match(sendEmail.args[0][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[0][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); assert.match(sendEmail.args[0][0].html, /This email was sent from Elaborate Fox<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[0][0].html, /Elaborate Fox integration expected Ghost version:<\/strong>  v4.5/); assert.match(sendEmail.args[0][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[0][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); assert.match(sendEmail.args[0][0].html, /This email was sent from Elaborate Fox<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[1][0].html, /Elaborate Fox integration expected Ghost version:<\/strong>  v4.5/); assert.match(sendEmail.args[1][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[1][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); assert.match(sendEmail.args[1][0].html, /This email was sent from Elaborate Fox<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[2][0].html, /Elaborate Fox integration expected Ghost version:<\/strong>  v4.8/); assert.match(sendEmail.args[2][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[2][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); + assert.match(sendEmail.args[2][0].text, /Ghost has noticed that your Elaborate Fox is no longer working as expected\./); assert.match(sendEmail.args[2][0].text, /Elaborate Fox integration expected Ghost version:v4.8/); assert.match(sendEmail.args[2][0].text, /Current Ghost version:v5.1/); + assert.match(sendEmail.args[2][0].text, /Failed request URL:/); + assert.match(sendEmail.args[2][0].text, /https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); }); it('Trims down the name of the integration when a lot of meta information is present in user-agent header', async function (){ @@ -192,7 +213,8 @@ describe('APIVersionCompatibilityService', function () { await compatibilityService.handleMismatch({ acceptVersion: 'v4.5', contentVersion: 'v5.1', - userAgent: 'Fancy Pants/2.3 GhostAdminSDK/2.4.0' + userAgent: 'Fancy Pants/2.3 GhostAdminSDK/2.4.0', + requestURL: 'https://amazeballsghostsite.com/ghost/api/admin/posts/dew023d9203se4' }); assert.equal(sendEmail.called, true); @@ -202,6 +224,7 @@ describe('APIVersionCompatibilityService', function () { assert.match(sendEmail.args[0][0].html, /Ghost has noticed that your Fancy Pants<\/strong> is no longer working as expected\./); assert.match(sendEmail.args[0][0].html, /Fancy Pants integration expected Ghost version:<\/strong>  v4.5/); assert.match(sendEmail.args[0][0].html, /Current Ghost version:<\/strong>  v5.1/); + assert.match(sendEmail.args[0][0].html, /Failed request URL:<\/strong>  https:\/\/amazeballsghostsite.com\/ghost\/api\/admin\/posts\/dew023d9203se4/); assert.match(sendEmail.args[0][0].html, /This email was sent from