feat: user preferences for archive download size (#10296)

* feat: user preferences for archive download size

* chore: open api

* chore: clean up

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Daniel Dietzler 2024-06-14 17:27:12 +02:00 committed by GitHub
parent 596412cb8f
commit dddc06c3b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 442 additions and 24 deletions

View file

@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, ValidateNested } from 'class-validator';
import { IsEnum, IsInt, IsPositive, ValidateNested } from 'class-validator';
import { UserAvatarColor, UserPreferences } from 'src/entities/user-metadata.entity';
import { Optional, ValidateBoolean } from 'src/validation';
@ -27,6 +27,14 @@ class EmailNotificationsUpdate {
albumUpdate?: boolean;
}
class DownloadUpdate {
@Optional()
@IsInt()
@IsPositive()
@ApiProperty({ type: 'integer' })
archiveSize?: number;
}
export class UserPreferencesUpdateDto {
@Optional()
@ValidateNested()
@ -42,6 +50,11 @@ export class UserPreferencesUpdateDto {
@ValidateNested()
@Type(() => EmailNotificationsUpdate)
emailNotifications?: EmailNotificationsUpdate;
@Optional()
@ValidateNested()
@Type(() => DownloadUpdate)
download?: DownloadUpdate;
}
class AvatarResponse {
@ -59,10 +72,16 @@ class EmailNotificationsResponse {
albumUpdate!: boolean;
}
class DownloadResponse {
@ApiProperty({ type: 'integer' })
archiveSize!: number;
}
export class UserPreferencesResponseDto implements UserPreferences {
memories!: MemoryResponse;
avatar!: AvatarResponse;
emailNotifications!: EmailNotificationsResponse;
download!: DownloadResponse;
}
export const mapPreferences = (preferences: UserPreferences): UserPreferencesResponseDto => {