From 52f4a3cfad1b56cfe46515ffba217b36b909209c Mon Sep 17 00:00:00 2001 From: EJS00102 <52255287+EJS00102@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:08:34 +0200 Subject: [PATCH] Made change as suggested --- packages/api/src/controllers/v1/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/api/src/controllers/v1/index.ts b/packages/api/src/controllers/v1/index.ts index 90978db..9be09ff 100644 --- a/packages/api/src/controllers/v1/index.ts +++ b/packages/api/src/controllers/v1/index.ts @@ -78,15 +78,12 @@ export class V1 { redis.del(Keys.Contact.id(contact.id)); redis.del(Keys.Contact.email(project.id, contact.email)); } else { - if (subscribed !== undefined && contact.subscribed !== subscribed) { - contact = await prisma.contact.update({ - where: { id: contact.id }, - data: { subscribed: subscribed ?? true }, - }); - + if (subscribed !== null && contact.subscribed !== subscribed) { + contact = await prisma.contact.update({where: {id: contact.id}, data: {subscribed}}); + redis.del(Keys.Contact.id(contact.id)); redis.del(Keys.Contact.email(project.id, contact.email)); - } + } } if (data) {