From b96c95beda468a780a57fa68851eae375f884102 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Thu, 26 Jun 2025 13:24:57 -0400 Subject: [PATCH] refactor(server): sync service (#19559) --- open-api/immich-openapi-specs.json | 1 + server/src/dtos/sync.dto.ts | 3 ++- server/src/services/sync.service.ts | 5 +---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 129c120286..9ac60e2a54 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -13425,6 +13425,7 @@ "properties": { "acks": { "items": { + "maxLength": 1000, "type": "string" }, "type": "array" diff --git a/server/src/dtos/sync.dto.ts b/server/src/dtos/sync.dto.ts index 7385edf400..7a15c2e456 100644 --- a/server/src/dtos/sync.dto.ts +++ b/server/src/dtos/sync.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum, IsInt, IsPositive, IsString } from 'class-validator'; +import { IsEnum, IsInt, IsPositive, IsString, MaxLength } from 'class-validator'; import { AssetResponseDto } from 'src/dtos/asset-response.dto'; import { AlbumUserRole, AssetOrder, AssetType, AssetVisibility, SyncEntityType, SyncRequestType } from 'src/enum'; import { Optional, ValidateDate, ValidateUUID } from 'src/validation'; @@ -217,6 +217,7 @@ export class SyncAckDto { } export class SyncAckSetDto { + @MaxLength(1000) @IsString({ each: true }) acks!: string[]; } diff --git a/server/src/services/sync.service.ts b/server/src/services/sync.service.ts index 47189cb033..484065bcc9 100644 --- a/server/src/services/sync.service.ts +++ b/server/src/services/sync.service.ts @@ -96,10 +96,7 @@ export class SyncService extends BaseService { throw new BadRequestException(`Invalid ack type: ${type}`); } - if (checkpoints[type]) { - throw new BadRequestException('Only one ack per type is allowed'); - } - + // TODO pick the latest ack for each type, instead of using the last one checkpoints[type] = { sessionId, type, ack }; }