Add per-document control over who can see viewer insights (#5594)

This commit is contained in:
Tom Moor
2023-07-23 12:01:36 -04:00
committed by GitHub
parent caf7333682
commit 479b805613
14 changed files with 192 additions and 73 deletions

View File

@@ -277,6 +277,20 @@ allow(User, "archive", Document, (user, document) => {
return user.teamId === document.teamId;
});
allow(User, "updateInsights", Document, (user, document) => {
if (!document || !document.isActive || document.isDraft) {
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, "unarchive", Document, (user, document) => {
if (!document) {
return false;