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

Merged v5.42.3 into main

This commit is contained in:
Ghost CI 2023-04-12 04:38:27 +01:00
commit 8571011e7d
4 changed files with 29 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ghost-admin",
"version": "5.42.2",
"version": "5.42.3",
"description": "Ember.js admin client for Ghost",
"author": "Ghost Foundation",
"homepage": "http://ghost.org",
@ -184,4 +184,4 @@
"path-browserify": "1.0.1",
"webpack": "5.77.0"
}
}
}

View file

@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "5.42.2",
"version": "5.42.3",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",

View file

@ -129,7 +129,11 @@ class EmailEventStorage {
}
async unsubscribeFromNewsletters(event) {
await this.#membersRepository.update({newsletters: []}, {id: event.memberId});
try {
await this.#membersRepository.update({newsletters: []}, {id: event.memberId});
} catch (err) {
logging.error(err);
}
}
}

View file

@ -466,6 +466,27 @@ describe('Email Event Storage', function () {
assert(update.firstCall.args[0].newsletters.length === 0);
});
it('Handles unsubscribe with a non-existent member', async function () {
const event = EmailUnsubscribedEvent.create({
email: 'example@example.com',
memberId: '123',
emailId: '456',
timestamp: new Date(0)
});
const error = new Error('Member not found');
const update = sinon.stub().throws(error);
const eventHandler = new EmailEventStorage({
membersRepository: {
update
}
});
await eventHandler.handleUnsubscribed(event);
assert(update.calledOnce);
assert(update.firstCall.args[0].newsletters.length === 0);
});
it('Handles complaints', async function () {
const event = SpamComplaintEvent.create({
email: 'example@example.com',