fix: Should be able to unstar archived and trashed documents (#2983)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user