mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
chore(web): change license wording and other things (#11309)
This commit is contained in:
parent
bc20710c6d
commit
ef7a6bb246
40 changed files with 1045 additions and 518 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsEnum, IsInt, IsPositive, ValidateNested } from 'class-validator';
|
||||
import { IsDateString, IsEnum, IsInt, IsPositive, ValidateNested } from 'class-validator';
|
||||
import { UserAvatarColor, UserPreferences } from 'src/entities/user-metadata.entity';
|
||||
import { Optional, ValidateBoolean } from 'src/validation';
|
||||
|
||||
|
|
@ -35,6 +35,15 @@ class DownloadUpdate {
|
|||
archiveSize?: number;
|
||||
}
|
||||
|
||||
class PurchaseUpdate {
|
||||
@ValidateBoolean({ optional: true })
|
||||
showSupportBadge?: boolean;
|
||||
|
||||
@IsDateString()
|
||||
@Optional()
|
||||
hideBuyButtonUntil?: string;
|
||||
}
|
||||
|
||||
export class UserPreferencesUpdateDto {
|
||||
@Optional()
|
||||
@ValidateNested()
|
||||
|
|
@ -55,6 +64,11 @@ export class UserPreferencesUpdateDto {
|
|||
@ValidateNested()
|
||||
@Type(() => DownloadUpdate)
|
||||
download?: DownloadUpdate;
|
||||
|
||||
@Optional()
|
||||
@ValidateNested()
|
||||
@Type(() => PurchaseUpdate)
|
||||
purchase?: PurchaseUpdate;
|
||||
}
|
||||
|
||||
class AvatarResponse {
|
||||
|
|
@ -77,11 +91,17 @@ class DownloadResponse {
|
|||
archiveSize!: number;
|
||||
}
|
||||
|
||||
class PurchaseResponse {
|
||||
showSupportBadge!: boolean;
|
||||
hideBuyButtonUntil!: string;
|
||||
}
|
||||
|
||||
export class UserPreferencesResponseDto implements UserPreferences {
|
||||
memories!: MemoryResponse;
|
||||
avatar!: AvatarResponse;
|
||||
emailNotifications!: EmailNotificationsResponse;
|
||||
download!: DownloadResponse;
|
||||
purchase!: PurchaseResponse;
|
||||
}
|
||||
|
||||
export const mapPreferences = (preferences: UserPreferences): UserPreferencesResponseDto => {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ export interface UserPreferences {
|
|||
download: {
|
||||
archiveSize: number;
|
||||
};
|
||||
purchase: {
|
||||
showSupportBadge: boolean;
|
||||
hideBuyButtonUntil: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const getDefaultPreferences = (user: { email: string }): UserPreferences => {
|
||||
|
|
@ -68,6 +72,10 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
|
|||
download: {
|
||||
archiveSize: HumanReadableSize.GiB * 4,
|
||||
},
|
||||
purchase: {
|
||||
showSupportBadge: true,
|
||||
hideBuyButtonUntil: new Date(2022, 1, 12).toISOString(),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ describe('getKeysDeep', () => {
|
|||
foo: 'bar',
|
||||
flag: true,
|
||||
count: 42,
|
||||
date: new Date(),
|
||||
}),
|
||||
).toEqual(['foo', 'flag', 'count']);
|
||||
).toEqual(['foo', 'flag', 'count', 'date']);
|
||||
});
|
||||
|
||||
it('should skip undefined properties', () => {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export const getKeysDeep = (target: unknown, path: string[] = []) => {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (_.isObject(value) && !_.isArray(value)) {
|
||||
if (_.isObject(value) && !_.isArray(value) && !_.isDate(value)) {
|
||||
properties.push(...getKeysDeep(value, [...path, key]));
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue