diff --git a/src/media/media-upload.dto.ts b/src/media/media-upload.dto.ts index 0ba14cf33..da82d9096 100644 --- a/src/media/media-upload.dto.ts +++ b/src/media/media-upload.dto.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { IsDate, IsString } from 'class-validator'; +import { IsDate, IsOptional, IsString } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; export class MediaUploadDto { @@ -21,8 +21,9 @@ export class MediaUploadDto { * @example "noteId" TODO how looks a note id? */ @IsString() + @IsOptional() @ApiProperty() - noteId: string; + noteId?: string; /** * The date when the upload objects was created. diff --git a/src/media/media.service.ts b/src/media/media.service.ts index 5debe2d59..4054c5f0f 100644 --- a/src/media/media.service.ts +++ b/src/media/media.service.ts @@ -227,7 +227,7 @@ export class MediaService { toMediaUploadDto(mediaUpload: MediaUpload): MediaUploadDto { return { url: mediaUpload.fileUrl, - noteId: mediaUpload.note.id, + noteId: mediaUpload.note?.id, createdAt: mediaUpload.createdAt, userName: mediaUpload.user.userName, };