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.ownerId !== ctx.websocket?.me?.id &&
|
||||
!document.collaborators.some((c) =>
|
||||
c.userId === ctx.websocket?.me?.id &&
|
||||
(c.writable || c.readable)
|
||||
)
|
||||
!document.collaborators.some((c) => c.userId === ctx.websocket?.me?.id && (c.writable || c.readable))
|
||||
) {
|
||||
throw new Error('User is not owner or collaborator of document')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user