From ea63b45a13005fe077994af991eb823a3d6a6a13 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Fri, 14 Jun 2024 10:00:14 +0000 Subject: [PATCH] fix: add recipients filter for bin --- .../server-only/document/find-documents.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/lib/server-only/document/find-documents.ts b/packages/lib/server-only/document/find-documents.ts index a94bbb02b..8eda0bbb2 100644 --- a/packages/lib/server-only/document/find-documents.ts +++ b/packages/lib/server-only/document/find-documents.ts @@ -168,9 +168,24 @@ export const findDocuments = async ({ } if (status === ExtendedDocumentStatus.BIN) { - whereClause.deletedAt = { - gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), - }; + whereClause.OR = [ + { + userId: user.id, + deletedAt: { + gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), + }, + }, + { + Recipient: { + some: { + email: user.email, + documentDeletedAt: { + gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), + }, + }, + }, + }, + ]; } if (senderIds && senderIds.length > 0) {