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:
2024-12-09 17:11:18 +07:00
parent 8d0b80f09c
commit 56762e98eb

View File

@@ -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')
} }