2024-05-27 22:16:53 -04:00
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
|
import { Type } from 'class-transformer';
|
2025-07-15 13:14:57 -04:00
|
|
|
import { IsDateString, IsInt, IsPositive, ValidateNested } from 'class-validator';
|
2025-06-06 06:31:34 +02:00
|
|
|
import { AssetOrder, UserAvatarColor } from 'src/enum';
|
2025-04-09 11:45:30 -04:00
|
|
|
import { UserPreferences } from 'src/types';
|
2025-07-15 13:14:57 -04:00
|
|
|
import { Optional, ValidateBoolean, ValidateEnum } from 'src/validation';
|
2024-05-27 22:16:53 -04:00
|
|
|
|
|
|
|
|
class AvatarUpdate {
|
2025-07-15 13:14:57 -04:00
|
|
|
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', optional: true })
|
2024-05-27 22:16:53 -04:00
|
|
|
color?: UserAvatarColor;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class MemoriesUpdate {
|
2024-05-27 22:16:53 -04:00
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
2025-10-08 22:37:34 +02:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@IsInt()
|
|
|
|
|
@IsPositive()
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
duration?: number;
|
2024-05-27 22:16:53 -04:00
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class RatingsUpdate {
|
2024-08-09 19:45:52 +02:00
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-06 06:31:34 +02:00
|
|
|
class AlbumsUpdate {
|
2025-07-15 13:14:57 -04:00
|
|
|
@ValidateEnum({ enum: AssetOrder, name: 'AssetOrder', optional: true })
|
2025-06-06 06:31:34 +02:00
|
|
|
defaultAssetOrder?: AssetOrder;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class FoldersUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
sidebarWeb?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PeopleUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
sidebarWeb?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-07 13:05:15 -05:00
|
|
|
class SharedLinksUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
sidebarWeb?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class TagsUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
sidebarWeb?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-03 16:00:20 -05:00
|
|
|
class EmailNotificationsUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
albumInvite?: boolean;
|
|
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
albumUpdate?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-15 16:06:16 -04:00
|
|
|
class DownloadUpdate implements Partial<DownloadResponse> {
|
2024-06-14 17:27:12 +02:00
|
|
|
@Optional()
|
|
|
|
|
@IsInt()
|
|
|
|
|
@IsPositive()
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
archiveSize?: number;
|
2024-08-15 16:06:16 -04:00
|
|
|
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
includeEmbeddedVideos?: boolean;
|
2024-06-14 17:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-26 10:34:35 -05:00
|
|
|
class PurchaseUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
showSupportBadge?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsDateString()
|
|
|
|
|
@Optional()
|
|
|
|
|
hideBuyButtonUntil?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-28 15:57:36 -05:00
|
|
|
class CastUpdate {
|
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
|
|
|
gCastEnabled?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 22:16:53 -04:00
|
|
|
export class UserPreferencesUpdateDto {
|
2025-06-06 06:31:34 +02:00
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => AlbumsUpdate)
|
|
|
|
|
albums?: AlbumsUpdate;
|
|
|
|
|
|
2024-08-09 19:45:52 +02:00
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
2024-08-29 14:29:04 -05:00
|
|
|
@Type(() => FoldersUpdate)
|
|
|
|
|
folders?: FoldersUpdate;
|
2024-08-09 19:45:52 +02:00
|
|
|
|
2024-05-27 22:16:53 -04:00
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
2024-08-29 14:29:04 -05:00
|
|
|
@Type(() => MemoriesUpdate)
|
|
|
|
|
memories?: MemoriesUpdate;
|
2024-05-27 22:16:53 -04:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
2024-08-29 14:29:04 -05:00
|
|
|
@Type(() => PeopleUpdate)
|
|
|
|
|
people?: PeopleUpdate;
|
|
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => RatingsUpdate)
|
|
|
|
|
ratings?: RatingsUpdate;
|
|
|
|
|
|
2025-02-07 13:05:15 -05:00
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => SharedLinksUpdate)
|
|
|
|
|
sharedLinks?: SharedLinksUpdate;
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => TagsUpdate)
|
|
|
|
|
tags?: TagsUpdate;
|
|
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => AvatarUpdate)
|
|
|
|
|
avatar?: AvatarUpdate;
|
2024-06-03 16:00:20 -05:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => EmailNotificationsUpdate)
|
|
|
|
|
emailNotifications?: EmailNotificationsUpdate;
|
2024-06-14 17:27:12 +02:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => DownloadUpdate)
|
|
|
|
|
download?: DownloadUpdate;
|
2024-07-26 10:34:35 -05:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => PurchaseUpdate)
|
|
|
|
|
purchase?: PurchaseUpdate;
|
2025-05-28 15:57:36 -05:00
|
|
|
|
|
|
|
|
@Optional()
|
|
|
|
|
@ValidateNested()
|
|
|
|
|
@Type(() => CastUpdate)
|
|
|
|
|
cast?: CastUpdate;
|
2024-05-27 22:16:53 -04:00
|
|
|
}
|
|
|
|
|
|
2025-06-06 06:31:34 +02:00
|
|
|
class AlbumsResponse {
|
2025-07-15 13:14:57 -04:00
|
|
|
@ValidateEnum({ enum: AssetOrder, name: 'AssetOrder' })
|
2025-07-15 14:50:13 -04:00
|
|
|
defaultAssetOrder: AssetOrder = AssetOrder.Desc;
|
2025-06-06 06:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class RatingsResponse {
|
2024-08-13 14:39:25 -05:00
|
|
|
enabled: boolean = false;
|
2024-08-09 19:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-29 14:29:04 -05:00
|
|
|
class MemoriesResponse {
|
|
|
|
|
enabled: boolean = true;
|
2025-10-08 22:37:34 +02:00
|
|
|
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
duration: number = 5;
|
2024-08-29 14:29:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FoldersResponse {
|
|
|
|
|
enabled: boolean = false;
|
|
|
|
|
sidebarWeb: boolean = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PeopleResponse {
|
|
|
|
|
enabled: boolean = true;
|
|
|
|
|
sidebarWeb: boolean = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TagsResponse {
|
|
|
|
|
enabled: boolean = true;
|
|
|
|
|
sidebarWeb: boolean = true;
|
2024-05-27 22:16:53 -04:00
|
|
|
}
|
|
|
|
|
|
2025-02-07 13:05:15 -05:00
|
|
|
class SharedLinksResponse {
|
|
|
|
|
enabled: boolean = true;
|
|
|
|
|
sidebarWeb: boolean = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-03 16:00:20 -05:00
|
|
|
class EmailNotificationsResponse {
|
|
|
|
|
enabled!: boolean;
|
|
|
|
|
albumInvite!: boolean;
|
|
|
|
|
albumUpdate!: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 17:27:12 +02:00
|
|
|
class DownloadResponse {
|
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
|
|
|
archiveSize!: number;
|
2024-08-15 16:06:16 -04:00
|
|
|
|
|
|
|
|
includeEmbeddedVideos: boolean = false;
|
2024-06-14 17:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-26 10:34:35 -05:00
|
|
|
class PurchaseResponse {
|
|
|
|
|
showSupportBadge!: boolean;
|
|
|
|
|
hideBuyButtonUntil!: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-28 15:57:36 -05:00
|
|
|
class CastResponse {
|
|
|
|
|
gCastEnabled: boolean = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 22:16:53 -04:00
|
|
|
export class UserPreferencesResponseDto implements UserPreferences {
|
2025-06-06 06:31:34 +02:00
|
|
|
albums!: AlbumsResponse;
|
2024-08-29 14:29:04 -05:00
|
|
|
folders!: FoldersResponse;
|
|
|
|
|
memories!: MemoriesResponse;
|
|
|
|
|
people!: PeopleResponse;
|
|
|
|
|
ratings!: RatingsResponse;
|
2025-02-07 13:05:15 -05:00
|
|
|
sharedLinks!: SharedLinksResponse;
|
2024-08-29 14:29:04 -05:00
|
|
|
tags!: TagsResponse;
|
2024-06-03 16:00:20 -05:00
|
|
|
emailNotifications!: EmailNotificationsResponse;
|
2024-06-14 17:27:12 +02:00
|
|
|
download!: DownloadResponse;
|
2024-07-26 10:34:35 -05:00
|
|
|
purchase!: PurchaseResponse;
|
2025-05-28 15:57:36 -05:00
|
|
|
cast!: CastResponse;
|
2024-05-27 22:16:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const mapPreferences = (preferences: UserPreferences): UserPreferencesResponseDto => {
|
|
|
|
|
return preferences;
|
|
|
|
|
};
|