fix: Should be able to unstar archived and trashed documents (#2983)

This commit is contained in:
Tom Moor
2022-01-26 19:39:06 -08:00
committed by GitHub
parent 9d82bf2a69
commit af8e74c373

View File

@@ -19,7 +19,7 @@ allow(User, ["read", "download"], Document, (user, document) => {
return user.teamId === document.teamId;
});
allow(User, ["star", "unstar"], Document, (user, document) => {
allow(User, "star", Document, (user, document) => {
if (!document) return false;
if (document.archivedAt) return false;
if (document.deletedAt) return false;
@@ -32,6 +32,17 @@ allow(User, ["star", "unstar"], Document, (user, document) => {
return user.teamId === document.teamId;
});
allow(User, "unstar", Document, (user, document) => {
if (!document) return false;
if (document.template) return false;
invariant(
document.collection,
"collection is missing, did you forget to include in the query scope?"
);
if (cannot(user, "read", document.collection)) return false;
return user.teamId === document.teamId;
});
allow(User, "share", Document, (user, document) => {
if (!document) return false;
if (document.archivedAt) return false;