mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 17:25:35 +03:00
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:
@@ -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 => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { UserEntity } from 'src/entities/user.entity';
|
||||
import { HumanReadableSize } from 'src/utils/bytes';
|
||||
import { Column, DeepPartial, Entity, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
|
||||
@Entity('user_metadata')
|
||||
@@ -41,6 +42,9 @@ export interface UserPreferences {
|
||||
albumInvite: boolean;
|
||||
albumUpdate: boolean;
|
||||
};
|
||||
download: {
|
||||
archiveSize: number;
|
||||
};
|
||||
}
|
||||
|
||||
export const getDefaultPreferences = (user: { email: string }): UserPreferences => {
|
||||
@@ -61,6 +65,9 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
|
||||
albumInvite: true,
|
||||
albumUpdate: true,
|
||||
},
|
||||
download: {
|
||||
archiveSize: HumanReadableSize.GiB * 4,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user