refactor: enhance schedule and document handling in schemas
- Simplify schedule expiration logic in CronService by removing unnecessary date checks. - Improve error handling in DocumentSchema for document page retrieval, ensuring graceful failure. - Add validation in ScheduleSchema to restrict schedule retrieval to authorized centers and prevent subscription-based access. - Implement checks to reject schedules with start dates in the past or today, enhancing data integrity.
This commit is contained in:
@@ -162,8 +162,12 @@ export class DocumentSchema extends PothosSchema {
|
||||
if (!ctx.http?.me?.id) throw new Error('User not found')
|
||||
if (!args.documentId) throw new Error('Document id not found')
|
||||
if (args.pageIndex === undefined || args.pageIndex === null) throw new Error('Page index not found')
|
||||
const delta = await this.minio.getDocumentPage(args.documentId, args.pageIndex)
|
||||
if (!delta) throw new Error('Delta not found')
|
||||
let delta
|
||||
try {
|
||||
delta = await this.minio.getDocumentPage(args.documentId, args.pageIndex)
|
||||
} catch (_error) {
|
||||
delta = null
|
||||
}
|
||||
const totalPage = await this.minio.countDocumentPages(args.documentId)
|
||||
return {
|
||||
documentId: args.documentId,
|
||||
@@ -172,6 +176,7 @@ export class DocumentSchema extends PothosSchema {
|
||||
totalPage,
|
||||
senderId: ctx.http?.me?.id,
|
||||
eventType: DocumentEvent.CLIENT_REQUEST_SYNC,
|
||||
requestSync: false,
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user