Notifications interface (#5354)
Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Comment,
|
||||
Document,
|
||||
Group,
|
||||
Notification,
|
||||
} from "@server/models";
|
||||
import { _abilities, _can, _cannot, _authorize } from "./cancan";
|
||||
import "./apiKey";
|
||||
@@ -26,6 +27,7 @@ import "./user";
|
||||
import "./team";
|
||||
import "./group";
|
||||
import "./webhookSubscription";
|
||||
import "./notification";
|
||||
|
||||
type Policy = Record<string, boolean>;
|
||||
|
||||
@@ -55,6 +57,7 @@ export function serialize(
|
||||
| Document
|
||||
| User
|
||||
| Group
|
||||
| Notification
|
||||
| null
|
||||
): Policy {
|
||||
const output = {};
|
||||
|
||||
9
server/policies/notification.ts
Normal file
9
server/policies/notification.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Notification, User } from "@server/models";
|
||||
import { allow } from "./cancan";
|
||||
|
||||
allow(User, ["read", "update"], Notification, (user, notification) => {
|
||||
if (!notification) {
|
||||
return false;
|
||||
}
|
||||
return user?.id === notification.userId;
|
||||
});
|
||||
Reference in New Issue
Block a user