mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(server): use date type for entities (#2602)
This commit is contained in:
@@ -61,7 +61,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity> {
|
||||
album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity)));
|
||||
album.updatedAt = new Date().toISOString();
|
||||
album.updatedAt = new Date();
|
||||
|
||||
await this.albumRepository.save(album);
|
||||
|
||||
@@ -71,7 +71,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
async removeUser(album: AlbumEntity, userId: string): Promise<void> {
|
||||
album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId);
|
||||
album.updatedAt = new Date().toISOString();
|
||||
album.updatedAt = new Date();
|
||||
await this.albumRepository.save(album);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
const numRemovedAssets = assetCount - album.assets.length;
|
||||
if (numRemovedAssets > 0) {
|
||||
album.updatedAt = new Date().toISOString();
|
||||
album.updatedAt = new Date();
|
||||
}
|
||||
await this.albumRepository.save(album, {});
|
||||
|
||||
@@ -111,7 +111,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
const successfullyAdded = addAssetsDto.assetIds.length - alreadyExisting.length;
|
||||
if (successfullyAdded > 0) {
|
||||
album.updatedAt = new Date().toISOString();
|
||||
album.updatedAt = new Date();
|
||||
}
|
||||
await this.albumRepository.save(album);
|
||||
|
||||
|
||||
@@ -32,8 +32,9 @@ describe('Album service', () => {
|
||||
...authUser,
|
||||
firstName: 'auth',
|
||||
lastName: 'user',
|
||||
createdAt: 'date',
|
||||
updatedAt: 'date',
|
||||
createdAt: new Date('2022-06-19T23:41:36.910Z'),
|
||||
deletedAt: null,
|
||||
updatedAt: new Date('2022-06-19T23:41:36.910Z'),
|
||||
profileImagePath: '',
|
||||
shouldChangePassword: false,
|
||||
oauthId: '',
|
||||
@@ -52,8 +53,8 @@ describe('Album service', () => {
|
||||
albumEntity.owner = albumOwner;
|
||||
albumEntity.id = albumId;
|
||||
albumEntity.albumName = 'name';
|
||||
albumEntity.createdAt = 'date';
|
||||
albumEntity.updatedAt = 'date';
|
||||
albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
|
||||
albumEntity.updatedAt = new Date('2022-06-19T23:41:36.910Z');
|
||||
albumEntity.sharedUsers = [];
|
||||
albumEntity.assets = [];
|
||||
albumEntity.albumThumbnailAssetId = null;
|
||||
@@ -67,7 +68,7 @@ describe('Album service', () => {
|
||||
albumEntity.owner = albumOwner;
|
||||
albumEntity.id = albumId;
|
||||
albumEntity.albumName = 'name';
|
||||
albumEntity.createdAt = 'date';
|
||||
albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
|
||||
albumEntity.assets = [];
|
||||
albumEntity.albumThumbnailAssetId = null;
|
||||
albumEntity.sharedUsers = [
|
||||
@@ -86,7 +87,7 @@ describe('Album service', () => {
|
||||
albumEntity.owner = albumOwner;
|
||||
albumEntity.id = albumId;
|
||||
albumEntity.albumName = 'name';
|
||||
albumEntity.createdAt = 'date';
|
||||
albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
|
||||
albumEntity.assets = [];
|
||||
albumEntity.albumThumbnailAssetId = null;
|
||||
albumEntity.sharedUsers = [
|
||||
@@ -109,7 +110,7 @@ describe('Album service', () => {
|
||||
albumEntity.ownerId = '5555';
|
||||
albumEntity.id = albumId;
|
||||
albumEntity.albumName = 'name';
|
||||
albumEntity.createdAt = 'date';
|
||||
albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
|
||||
albumEntity.sharedUsers = [];
|
||||
albumEntity.assets = [];
|
||||
albumEntity.albumThumbnailAssetId = null;
|
||||
@@ -158,8 +159,8 @@ describe('Album service', () => {
|
||||
owner: mapUser(albumOwner),
|
||||
id: albumId,
|
||||
albumName: 'name',
|
||||
createdAt: 'date',
|
||||
updatedAt: 'date',
|
||||
createdAt: new Date('2022-06-19T23:41:36.910Z'),
|
||||
updatedAt: new Date('2022-06-19T23:41:36.910Z'),
|
||||
sharedUsers: [],
|
||||
assets: [],
|
||||
albumThumbnailAssetId: null,
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ValidateUUID } from 'apps/immich/src/decorators/validate-uuid.decorator';
|
||||
import { IsBoolean, IsISO8601, IsOptional, IsString } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsDate, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class CreateAlbumShareLinkDto {
|
||||
@ValidateUUID()
|
||||
albumId!: string;
|
||||
|
||||
@IsISO8601()
|
||||
@IsOptional()
|
||||
@ApiProperty({ format: 'date-time' })
|
||||
expiresAt?: string;
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
@ApiProperty()
|
||||
expiresAt?: Date;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsArray, IsBoolean, IsDate, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class CreateAssetsShareLinkDto {
|
||||
@IsArray()
|
||||
@@ -17,9 +18,10 @@ export class CreateAssetsShareLinkDto {
|
||||
})
|
||||
assetIds!: string[];
|
||||
|
||||
@IsString()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
@IsOptional()
|
||||
expiresAt?: string;
|
||||
expiresAt?: Date;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
|
||||
@@ -21,9 +21,9 @@ describe('TagService', () => {
|
||||
email: 'testuser@email.com',
|
||||
profileImagePath: '',
|
||||
shouldChangePassword: true,
|
||||
createdAt: '2022-12-02T19:29:23.603Z',
|
||||
deletedAt: undefined,
|
||||
updatedAt: '2022-12-02T19:29:23.603Z',
|
||||
createdAt: new Date('2022-12-02T19:29:23.603Z'),
|
||||
deletedAt: null,
|
||||
updatedAt: new Date('2022-12-02T19:29:23.603Z'),
|
||||
tags: [],
|
||||
assets: [],
|
||||
oauthId: 'oauth-id-1',
|
||||
|
||||
Reference in New Issue
Block a user