feat: add description field to share

This commit is contained in:
Elias Schneider
2022-12-12 11:54:13 +01:00
parent 78dd4a7e2a
commit 8728fa5207
10 changed files with 108 additions and 73 deletions

View File

@@ -39,6 +39,7 @@ model Share {
isZipReady Boolean @default(false)
views Int @default(0)
expiration DateTime
description String?
creatorId String?
creator User? @relation(fields: [creatorId], references: [id], onDelete: Cascade)

View File

@@ -1,9 +1,11 @@
import { Type } from "class-transformer";
import {
IsEmail,
IsOptional,
IsString,
Length,
Matches,
MaxLength,
ValidateNested,
} from "class-validator";
import { ShareSecurityDTO } from "./shareSecurity.dto";
@@ -19,6 +21,10 @@ export class CreateShareDTO {
@IsString()
expiration: string;
@MaxLength(512)
@IsOptional()
description: string;
@IsEmail({}, { each: true })
recipients: string[];

View File

@@ -17,6 +17,9 @@ export class ShareDTO {
@Type(() => PublicUserDTO)
creator: PublicUserDTO;
@Expose()
description: string;
from(partial: Partial<ShareDTO>) {
return plainToClass(ShareDTO, partial, { excludeExtraneousValues: true });
}

View File

@@ -1,4 +1,4 @@
import { PickType } from "@nestjs/mapped-types";
import { UserDTO } from "./user.dto";
export class PublicUserDTO extends PickType(UserDTO, ["email"] as const) {}
export class PublicUserDTO extends PickType(UserDTO, ["username"] as const) {}