From 6d20caa072cd4751037672ec5e28a8bd464a25b1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 6 Sep 2026 17:25:13 +0900 Subject: [PATCH] fix: Load personalOwnerId when evaluating read policy in RevokeUserNotificationsTask The task's minimal attribute list predates the personal owner check in the read policy, and strict attributes turns the missing column into an error. Co-Authored-By: Claude Fable 5 --- .../tasks/RevokeUserNotificationsTask.test.ts | 33 +++++++++++++++++++ .../tasks/RevokeUserNotificationsTask.ts | 1 + 2 files changed, 34 insertions(+) diff --git a/server/queues/tasks/RevokeUserNotificationsTask.test.ts b/server/queues/tasks/RevokeUserNotificationsTask.test.ts index 2ab1ce95d5..d47105e00a 100644 --- a/server/queues/tasks/RevokeUserNotificationsTask.test.ts +++ b/server/queues/tasks/RevokeUserNotificationsTask.test.ts @@ -9,6 +9,7 @@ import { buildDocument, buildDraftDocument, buildNotification, + buildPersonalDocument, buildTeam, buildUser, } from "@server/test/factories"; @@ -40,6 +41,38 @@ describe("RevokeUserNotificationsTask", () => { expect(await Notification.findByPk(notification.id)).toBeNull(); }); + it("should revoke notifications for a personal document the user was removed from", async () => { + const team = await buildTeam(); + const owner = await buildUser({ teamId: team.id }); + const user = await buildUser({ teamId: team.id }); + const document = await buildPersonalDocument({ + teamId: team.id, + userId: owner.id, + }); + const notification = await buildNotification({ + teamId: team.id, + userId: user.id, + documentId: document.id, + }); + const ownerNotification = await buildNotification({ + teamId: team.id, + userId: owner.id, + documentId: document.id, + }); + + await new RevokeUserNotificationsTask().perform({ + userId: user.id, + documentId: document.id, + }); + await new RevokeUserNotificationsTask().perform({ + userId: owner.id, + documentId: document.id, + }); + + expect(await Notification.findByPk(notification.id)).toBeNull(); + expect(await Notification.findByPk(ownerNotification.id)).not.toBeNull(); + }); + it("should retain notifications when the user can still read the document", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); diff --git a/server/queues/tasks/RevokeUserNotificationsTask.ts b/server/queues/tasks/RevokeUserNotificationsTask.ts index a56d8e1b94..3eda7dcf13 100644 --- a/server/queues/tasks/RevokeUserNotificationsTask.ts +++ b/server/queues/tasks/RevokeUserNotificationsTask.ts @@ -57,6 +57,7 @@ export default class RevokeUserNotificationsTask extends BaseTask { "id", "teamId", "collectionId", + "personalOwnerId", "createdById", "publishedAt", ],