0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Moved InMemoryEmailSuppressionList to own file

This cleans up the service file so we can make the switch to a Mailgun specific
implementation later.
This commit is contained in:
Fabien "egg" O'Carroll 2022-11-30 18:34:41 +07:00 committed by Fabien 'egg' O'Carroll
parent c6c962d5d6
commit 5e72e42d32
2 changed files with 37 additions and 36 deletions

View file

@ -0,0 +1,36 @@
const {AbstractEmailSuppressionList, EmailSuppressionData} = require('@tryghost/email-suppression-list');
module.exports = class InMemoryEmailSuppressionList extends AbstractEmailSuppressionList {
store = ['spam@member.test', 'fail@member.test'];
async removeEmail(email) {
if ((email === 'fail@member.test' || email === 'spam@member.test') && this.store.includes(email)) {
this.store = this.store.filter(el => el !== email);
setTimeout(() => this.store.push(email), 3000);
return true;
}
return false;
}
async getSuppressionData(email) {
if (email === 'spam@member.test' && this.store.includes(email)) {
return new EmailSuppressionData(true, {
timestamp: new Date(),
reason: 'spam'
});
}
if (email === 'fail@member.test' && this.store.includes(email)) {
return new EmailSuppressionData(true, {
timestamp: new Date(),
reason: 'fail'
});
}
return new EmailSuppressionData(false);
}
async init() {
return;
}
};

View file

@ -1,38 +1,3 @@
const {AbstractEmailSuppressionList, EmailSuppressionData} = require('@tryghost/email-suppression-list');
class InMemoryEmailSuppressionList extends AbstractEmailSuppressionList {
store = ['spam@member.test', 'fail@member.test'];
async removeEmail(email) {
if ((email === 'fail@member.test' || email === 'spam@member.test') && this.store.includes(email)) {
this.store = this.store.filter(el => el !== email);
setTimeout(() => this.store.push(email), 3000);
return true;
}
return false;
}
async getSuppressionData(email) {
if (email === 'spam@member.test' && this.store.includes(email)) {
return new EmailSuppressionData(true, {
timestamp: new Date(),
reason: 'spam'
});
}
if (email === 'fail@member.test' && this.store.includes(email)) {
return new EmailSuppressionData(true, {
timestamp: new Date(),
reason: 'fail'
});
}
return new EmailSuppressionData(false);
}
async init() {
return;
}
}
const InMemoryEmailSuppressionList = require('./InMemoryEmailSuppressionList');
module.exports = new InMemoryEmailSuppressionList();