Notifications interface (#5354)

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
Tom Moor
2023-05-20 10:47:32 -04:00
committed by GitHub
parent b1e2ff0713
commit ea885133ac
49 changed files with 1918 additions and 163 deletions

View File

@@ -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 = {};

View 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;
});