mirror of
https://github.com/outline/outline.git
synced 2026-12-06 03:05:08 +03:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c223c48d1
commit
6d20caa072
2 files changed
+34
No files matched your search
@@ -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 });
|
||||
|
||||
@@ -57,6 +57,7 @@ export default class RevokeUserNotificationsTask extends BaseTask<Props> {
|
||||
"id",
|
||||
"teamId",
|
||||
"collectionId",
|
||||
"personalOwnerId",
|
||||
"createdById",
|
||||
"publishedAt",
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user