chore(web): change license wording and other things (#11309)

This commit is contained in:
Alex 2024-07-26 10:34:35 -05:00 committed by GitHub
parent bc20710c6d
commit ef7a6bb246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1045 additions and 518 deletions

View file

@ -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 => {

View file

@ -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(),
},
};
};

View file

@ -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', () => {

View file

@ -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;
}