diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap index cb39c5e572..46669eaa79 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap @@ -60,7 +60,7 @@ exports[`Members API - member attribution Can read member attributed to a page 2 Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "1082", + "content-length": "1094", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, @@ -129,7 +129,7 @@ exports[`Members API - member attribution Can read member attributed to a post 2 Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "1065", + "content-length": "1077", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, @@ -198,7 +198,7 @@ exports[`Members API - member attribution Can read member attributed to a tag 2: Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "1071", + "content-length": "1083", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, @@ -267,7 +267,7 @@ exports[`Members API - member attribution Can read member attributed to an autho Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "1053", + "content-length": "1065", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, @@ -336,7 +336,7 @@ exports[`Members API - member attribution Can read member attributed to an url 2 Object { "access-control-allow-origin": "http://127.0.0.1:2369", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", - "content-length": "1049", + "content-length": "1061", "content-type": "application/json; charset=utf-8", "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, diff --git a/ghost/members-api/lib/services/MemberBREADService.js b/ghost/members-api/lib/services/MemberBREADService.js index fdbaec210c..44def5be25 100644 --- a/ghost/members-api/lib/services/MemberBREADService.js +++ b/ghost/members-api/lib/services/MemberBREADService.js @@ -249,7 +249,7 @@ module.exports = class MemberBREADService { info: suppressionData.info }; - const unsubscribeUrl = this.settingsHelpers.createUnsubscribeUrl(member.id); + const unsubscribeUrl = this.settingsHelpers.createUnsubscribeUrl(member.uuid); member.unsubscribe_url = unsubscribeUrl; return member; @@ -432,7 +432,7 @@ module.exports = class MemberBREADService { suppressed: bulkSuppressionData[index].suppressed || !!model.get('email_disabled'), info: bulkSuppressionData[index].info }; - member.unsubscribe_url = this.settingsHelpers.createUnsubscribeUrl(member.id); + member.unsubscribe_url = this.settingsHelpers.createUnsubscribeUrl(member.uuid); return member; }); diff --git a/ghost/members-api/test/unit/lib/services/member-bread.test.js b/ghost/members-api/test/unit/lib/services/member-bread.test.js index f1cc6f4173..260820b7e1 100644 --- a/ghost/members-api/test/unit/lib/services/member-bread.test.js +++ b/ghost/members-api/test/unit/lib/services/member-bread.test.js @@ -6,6 +6,7 @@ const moment = require('moment'); describe('MemberBreadService', function () { describe('read', function () { const MEMBER_ID = 123; + const MEMBER_UUID = 'abcd-efgh'; const DEFAULT_RELATIONS = [ 'labels', 'stripeSubscriptions', @@ -27,7 +28,7 @@ describe('MemberBreadService', function () { const getService = () => { return new MemberBreadService({ settingsHelpers: { - createUnsubscribeUrl: sinon.stub().returns('https://example.com/unsubscribe/?uuid=123&key=456') + createUnsubscribeUrl: sinon.stub().callsFake(uuid => `https://example.com/unsubscribe/?uuid=${uuid}&key=456`) }, memberRepository: memberRepositoryStub, memberAttributionService: memberAttributionServiceStub, @@ -38,6 +39,7 @@ describe('MemberBreadService', function () { beforeEach(function () { memberModelJSON = { id: MEMBER_ID, + uuid: MEMBER_UUID, name: 'foo bar', email: 'foo@bar.baz', subscriptions: [] @@ -294,7 +296,7 @@ describe('MemberBreadService', function () { const memberBreadService = getService(); const member = await memberBreadService.read({id: MEMBER_ID}); - assert.equal(member.unsubscribe_url, 'https://example.com/unsubscribe/?uuid=123&key=456'); + assert.equal(member.unsubscribe_url, `https://example.com/unsubscribe/?uuid=${MEMBER_UUID}&key=456`); }); }); });