mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Updated unsubscribe url for preview email
no issue
This commit is contained in:
parent
e6f74c63db
commit
7209abb729
1 changed files with 8 additions and 3 deletions
|
@ -40,8 +40,8 @@ const sendTestEmail = async (postModel, emails) => {
|
||||||
const emailData = emails.reduce((emailData, email) => {
|
const emailData = emails.reduce((emailData, email) => {
|
||||||
return Object.assign({
|
return Object.assign({
|
||||||
[email]: {
|
[email]: {
|
||||||
unique_id: '',
|
unique_id: 'preview',
|
||||||
unsubscribe_url: ''
|
unsubscribe_url: createUnsubscribeUrl({})
|
||||||
}
|
}
|
||||||
}, emailData);
|
}, emailData);
|
||||||
}, {});
|
}, {});
|
||||||
|
@ -117,6 +117,7 @@ const serialize = async (model) => {
|
||||||
* createUnsubscribeUrl
|
* createUnsubscribeUrl
|
||||||
*
|
*
|
||||||
* Takes a member and returns the url that should be used to unsubscribe
|
* Takes a member and returns the url that should be used to unsubscribe
|
||||||
|
* In case of no member, generates the preview unsubscribe url - `?preview=1`
|
||||||
*
|
*
|
||||||
* @param {object} member
|
* @param {object} member
|
||||||
* @param {string} member.uuid
|
* @param {string} member.uuid
|
||||||
|
@ -125,7 +126,11 @@ function createUnsubscribeUrl(member) {
|
||||||
const siteUrl = urlUtils.getSiteUrl();
|
const siteUrl = urlUtils.getSiteUrl();
|
||||||
const unsubscribeUrl = new URL(siteUrl);
|
const unsubscribeUrl = new URL(siteUrl);
|
||||||
unsubscribeUrl.pathname = `${unsubscribeUrl.pathname}/unsubscribe/`.replace('//', '/');
|
unsubscribeUrl.pathname = `${unsubscribeUrl.pathname}/unsubscribe/`.replace('//', '/');
|
||||||
unsubscribeUrl.searchParams.set('uuid', member.uuid);
|
if (member.uuid) {
|
||||||
|
unsubscribeUrl.searchParams.set('uuid', member.uuid);
|
||||||
|
} else {
|
||||||
|
unsubscribeUrl.searchParams.set('preview', '1');
|
||||||
|
}
|
||||||
|
|
||||||
return unsubscribeUrl.href;
|
return unsubscribeUrl.href;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue