refactor: streamline collaborator check in Document schema
- Simplified the collaborator check logic in the DocumentSchema by condensing the condition into a single line for improved readability. - Maintained existing functionality while enhancing code clarity and maintainability.
This commit is contained in:
@@ -461,10 +461,7 @@ export class DocumentSchema extends PothosSchema {
|
|||||||
if (!document.isPublic) {
|
if (!document.isPublic) {
|
||||||
if (
|
if (
|
||||||
document.ownerId !== ctx.websocket?.me?.id &&
|
document.ownerId !== ctx.websocket?.me?.id &&
|
||||||
!document.collaborators.some((c) =>
|
!document.collaborators.some((c) => c.userId === ctx.websocket?.me?.id && (c.writable || c.readable))
|
||||||
c.userId === ctx.websocket?.me?.id &&
|
|
||||||
(c.writable || c.readable)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
throw new Error('User is not owner or collaborator of document')
|
throw new Error('User is not owner or collaborator of document')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user