From f051f9aeeb85f3b38234f5a3a8670badd32d1109 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Wed, 27 Apr 2022 19:03:33 +0200 Subject: [PATCH] Fixed bulk unsubscribe refs https://github.com/TryGhost/Team/issues/1567 - Deletes the newsletter relations instead of setting subscribed to false - Depends on these changes: https://github.com/TryGhost/Ghost/pull/14610 --- ghost/members-api/lib/repositories/member.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ghost/members-api/lib/repositories/member.js b/ghost/members-api/lib/repositories/member.js index 633c8517ec..920774eeab 100644 --- a/ghost/members-api/lib/repositories/member.js +++ b/ghost/members-api/lib/repositories/member.js @@ -587,11 +587,13 @@ module.exports = class MemberRepository { const memberIds = memberRows.map(row => row.id); if (data.action === 'unsubscribe') { - return await this._Member.bulkEdit(memberIds, 'members', { - data: { - subscribed: false - } + const memberNewsletterRows = await this._Member.getNewsletterRelations({ + memberIds }); + + const membersNewsletterIds = memberNewsletterRows.map(row => row.id); + + return await this._Member.bulkDestroy(membersNewsletterIds, 'members_newsletters'); } if (data.action === 'removeLabel') {