0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

🐛 Fixed malformed unsubscribe_url in members api response (#21437)

no ref
This commit is contained in:
Steve Larson 2024-10-28 09:58:09 -05:00
parent 2b2981205e
commit 00bd31a718
3 changed files with 11 additions and 9 deletions

View file

@ -60,7 +60,7 @@ exports[`Members API - member attribution Can read member attributed to a page 2
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "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-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "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 { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "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-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "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 { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "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-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "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 { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "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-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "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 { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "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-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,

View file

@ -249,7 +249,7 @@ module.exports = class MemberBREADService {
info: suppressionData.info info: suppressionData.info
}; };
const unsubscribeUrl = this.settingsHelpers.createUnsubscribeUrl(member.id); const unsubscribeUrl = this.settingsHelpers.createUnsubscribeUrl(member.uuid);
member.unsubscribe_url = unsubscribeUrl; member.unsubscribe_url = unsubscribeUrl;
return member; return member;
@ -432,7 +432,7 @@ module.exports = class MemberBREADService {
suppressed: bulkSuppressionData[index].suppressed || !!model.get('email_disabled'), suppressed: bulkSuppressionData[index].suppressed || !!model.get('email_disabled'),
info: bulkSuppressionData[index].info info: bulkSuppressionData[index].info
}; };
member.unsubscribe_url = this.settingsHelpers.createUnsubscribeUrl(member.id); member.unsubscribe_url = this.settingsHelpers.createUnsubscribeUrl(member.uuid);
return member; return member;
}); });

View file

@ -6,6 +6,7 @@ const moment = require('moment');
describe('MemberBreadService', function () { describe('MemberBreadService', function () {
describe('read', function () { describe('read', function () {
const MEMBER_ID = 123; const MEMBER_ID = 123;
const MEMBER_UUID = 'abcd-efgh';
const DEFAULT_RELATIONS = [ const DEFAULT_RELATIONS = [
'labels', 'labels',
'stripeSubscriptions', 'stripeSubscriptions',
@ -27,7 +28,7 @@ describe('MemberBreadService', function () {
const getService = () => { const getService = () => {
return new MemberBreadService({ return new MemberBreadService({
settingsHelpers: { 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, memberRepository: memberRepositoryStub,
memberAttributionService: memberAttributionServiceStub, memberAttributionService: memberAttributionServiceStub,
@ -38,6 +39,7 @@ describe('MemberBreadService', function () {
beforeEach(function () { beforeEach(function () {
memberModelJSON = { memberModelJSON = {
id: MEMBER_ID, id: MEMBER_ID,
uuid: MEMBER_UUID,
name: 'foo bar', name: 'foo bar',
email: 'foo@bar.baz', email: 'foo@bar.baz',
subscriptions: [] subscriptions: []
@ -294,7 +296,7 @@ describe('MemberBreadService', function () {
const memberBreadService = getService(); const memberBreadService = getService();
const member = await memberBreadService.read({id: MEMBER_ID}); 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`);
}); });
}); });
}); });