feat: Document subscriptions (#3834)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
CuriousCorrelation
2022-08-26 12:17:13 +05:30
committed by GitHub
parent 864f585e5b
commit 24c71c38a5
36 changed files with 2594 additions and 165 deletions

View File

@@ -151,31 +151,36 @@ allow(User, "move", Document, (user, document) => {
return user.teamId === document.teamId;
});
allow(User, ["pin", "unpin"], Document, (user, document) => {
if (!document) {
return false;
allow(
User,
["pin", "unpin", "subscribe", "unsubscribe"],
Document,
(user, document) => {
if (!document) {
return false;
}
if (document.archivedAt) {
return false;
}
if (document.deletedAt) {
return false;
}
if (document.template) {
return false;
}
if (!document.publishedAt) {
return false;
}
invariant(
document.collection,
"collection is missing, did you forget to include in the query scope?"
);
if (cannot(user, "update", document.collection)) {
return false;
}
return user.teamId === document.teamId;
}
if (document.archivedAt) {
return false;
}
if (document.deletedAt) {
return false;
}
if (document.template) {
return false;
}
if (!document.publishedAt) {
return false;
}
invariant(
document.collection,
"collection is missing, did you forget to include in the query scope?"
);
if (cannot(user, "update", document.collection)) {
return false;
}
return user.teamId === document.teamId;
});
);
allow(User, ["pinToHome"], Document, (user, document) => {
if (!document) {