Refactor DocumentSchema to remove fileUrl retrieval logic and set default value for fileUrl. This change simplifies the document creation process by eliminating unnecessary error handling related to file retrieval, while maintaining user ownership assignment.

This commit is contained in:
2024-11-27 08:56:29 +07:00
parent 0bfdd3812d
commit a6788345ce

View File

@@ -136,13 +136,13 @@ export class DocumentSchema extends PothosSchema {
if (ctx.isSubscription) throw new Error('Not allowed')
const userId = ctx.http?.me?.id
if (!userId) throw new Error('User not found')
const fileUrl = await this.minio.getFileUrl('document', 'document', 'document')
if (!fileUrl) throw new Error('File not found')
// const fileUrl = await this.minio.getFileUrl('document', 'document', 'document')
// if (!fileUrl) throw new Error('File not found')
const document = await this.prisma.document.create({
...query,
data: {
name: 'Untitled',
fileUrl,
fileUrl: '', // fileUrl,
ownerId: userId,
},
})