MediaUploadDto: Make noteId optional

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-04-29 16:59:40 +02:00
parent dc7d8ab470
commit b08a314863
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
2 changed files with 4 additions and 3 deletions

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only * 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'; import { ApiProperty } from '@nestjs/swagger';
export class MediaUploadDto { export class MediaUploadDto {
@ -21,8 +21,9 @@ export class MediaUploadDto {
* @example "noteId" TODO how looks a note id? * @example "noteId" TODO how looks a note id?
*/ */
@IsString() @IsString()
@IsOptional()
@ApiProperty() @ApiProperty()
noteId: string; noteId?: string;
/** /**
* The date when the upload objects was created. * The date when the upload objects was created.

View file

@ -227,7 +227,7 @@ export class MediaService {
toMediaUploadDto(mediaUpload: MediaUpload): MediaUploadDto { toMediaUploadDto(mediaUpload: MediaUpload): MediaUploadDto {
return { return {
url: mediaUpload.fileUrl, url: mediaUpload.fileUrl,
noteId: mediaUpload.note.id, noteId: mediaUpload.note?.id,
createdAt: mediaUpload.createdAt, createdAt: mediaUpload.createdAt,
userName: mediaUpload.user.userName, userName: mediaUpload.user.userName,
}; };