3c5cf21274
refs: https://github.com/TryGhost/Toolbox/issues/166 New package handles the email verification workflow to prevent spammers. It currently handles MembersSubscribeEvent to detect potential abuse of the API to add members, and exposes methods for checking the threshold / starting the verification process for use by other areas of the code (at the moment - just member imports). The import package no longer needs to handle anything related to verification since it can be handled in the wrapper function in Ghost, and the API package doesn't need to do anything other than dispatch the new event.
25 lines
561 B
JavaScript
25 lines
561 B
JavaScript
/**
|
|
* @typedef {object} MemberSubscribeEventData
|
|
* @prop {string} memberId
|
|
* @prop {string} source
|
|
*/
|
|
|
|
module.exports = class MemberSubscribeEvent {
|
|
/**
|
|
* @param {MemberSubscribeEventData} data
|
|
* @param {Date} timestamp
|
|
*/
|
|
constructor(data, timestamp) {
|
|
this.data = data;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
/**
|
|
* @param {MemberSubscribeEventData} data
|
|
* @param {Date} [timestamp]
|
|
*/
|
|
static create(data, timestamp) {
|
|
return new MemberSubscribeEvent(data, timestamp || new Date);
|
|
}
|
|
};
|