mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added createUnsubscribeUrl fn to mega
no-issue
This commit is contained in:
parent
4db260f17e
commit
00db1d385c
1 changed files with 20 additions and 1 deletions
|
@ -6,6 +6,7 @@ const membersService = require('../members');
|
||||||
const bulkEmailService = require('../bulk-email');
|
const bulkEmailService = require('../bulk-email');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
const postEmailSerializer = require('./post-email-serializer');
|
const postEmailSerializer = require('./post-email-serializer');
|
||||||
|
const urlUtils = require('../../lib/url-utils');
|
||||||
|
|
||||||
const sendEmail = async (post, members) => {
|
const sendEmail = async (post, members) => {
|
||||||
const emailTmpl = postEmailSerializer.serialize(post);
|
const emailTmpl = postEmailSerializer.serialize(post);
|
||||||
|
@ -39,6 +40,23 @@ const serialize = async (model) => {
|
||||||
return frame.response[docName][0];
|
return frame.response[docName][0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* createUnsubscribeUrl
|
||||||
|
*
|
||||||
|
* Takes a member and returns the url that should be used to unsubscribe
|
||||||
|
*
|
||||||
|
* @param {object} member
|
||||||
|
* @param {string} member.uuid
|
||||||
|
*/
|
||||||
|
function createUnsubscribeUrl(member) {
|
||||||
|
const siteUrl = urlUtils.getSiteUrl();
|
||||||
|
const unsubscribeUrl = new URL(siteUrl);
|
||||||
|
unsubscribeUrl.searchParams.set('action', 'unsubscribe');
|
||||||
|
unsubscribeUrl.searchParams.set('unsubscribe', member.uuid);
|
||||||
|
|
||||||
|
return unsubscribeUrl.href;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handleUnsubscribeRequest
|
* handleUnsubscribeRequest
|
||||||
*
|
*
|
||||||
|
@ -151,5 +169,6 @@ function listen() {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
listen,
|
listen,
|
||||||
sendTestEmail,
|
sendTestEmail,
|
||||||
handleUnsubscribeRequest
|
handleUnsubscribeRequest,
|
||||||
|
createUnsubscribeUrl
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue