From 7b1562c050c2f095382e9f3842d5cc853fa7029c Mon Sep 17 00:00:00 2001 From: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> Date: Mon, 8 Apr 2024 22:00:08 +0200 Subject: [PATCH] fix(server): remove isWatched from DTO (#8598) * fix: remove isWatched * chore: open api --- mobile/openapi/doc/CreateLibraryDto.md | 1 - .../openapi/lib/model/create_library_dto.dart | 19 +------------------ .../openapi/test/create_library_dto_test.dart | 5 ----- open-api/immich-openapi-specs.json | 3 --- open-api/typescript-sdk/src/fetch-client.ts | 1 - server/src/dtos/library.dto.ts | 3 --- server/src/services/library.service.spec.ts | 8 -------- server/src/services/library.service.ts | 3 --- .../admin/library-management/+page.svelte | 4 +++- 9 files changed, 4 insertions(+), 43 deletions(-) diff --git a/mobile/openapi/doc/CreateLibraryDto.md b/mobile/openapi/doc/CreateLibraryDto.md index 94e96493ec..01a2a0f917 100644 --- a/mobile/openapi/doc/CreateLibraryDto.md +++ b/mobile/openapi/doc/CreateLibraryDto.md @@ -11,7 +11,6 @@ Name | Type | Description | Notes **exclusionPatterns** | **List** | | [optional] [default to const []] **importPaths** | **List** | | [optional] [default to const []] **isVisible** | **bool** | | [optional] -**isWatched** | **bool** | | [optional] **name** | **String** | | [optional] **ownerId** | **String** | | **type** | [**LibraryType**](LibraryType.md) | | diff --git a/mobile/openapi/lib/model/create_library_dto.dart b/mobile/openapi/lib/model/create_library_dto.dart index 24cc045300..93fb89b701 100644 --- a/mobile/openapi/lib/model/create_library_dto.dart +++ b/mobile/openapi/lib/model/create_library_dto.dart @@ -16,7 +16,6 @@ class CreateLibraryDto { this.exclusionPatterns = const [], this.importPaths = const [], this.isVisible, - this.isWatched, this.name, required this.ownerId, required this.type, @@ -34,14 +33,6 @@ class CreateLibraryDto { /// bool? isVisible; - /// - /// Please note: This property should have been non-nullable! Since the specification file - /// does not include a default value (using the "default:" property), however, the generated - /// source code must fall back to having a nullable type. - /// Consider adding a "default:" property in the specification file to hide this note. - /// - bool? isWatched; - /// /// Please note: This property should have been non-nullable! Since the specification file /// does not include a default value (using the "default:" property), however, the generated @@ -59,7 +50,6 @@ class CreateLibraryDto { _deepEquality.equals(other.exclusionPatterns, exclusionPatterns) && _deepEquality.equals(other.importPaths, importPaths) && other.isVisible == isVisible && - other.isWatched == isWatched && other.name == name && other.ownerId == ownerId && other.type == type; @@ -70,13 +60,12 @@ class CreateLibraryDto { (exclusionPatterns.hashCode) + (importPaths.hashCode) + (isVisible == null ? 0 : isVisible!.hashCode) + - (isWatched == null ? 0 : isWatched!.hashCode) + (name == null ? 0 : name!.hashCode) + (ownerId.hashCode) + (type.hashCode); @override - String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, isVisible=$isVisible, isWatched=$isWatched, name=$name, ownerId=$ownerId, type=$type]'; + String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, isVisible=$isVisible, name=$name, ownerId=$ownerId, type=$type]'; Map toJson() { final json = {}; @@ -87,11 +76,6 @@ class CreateLibraryDto { } else { // json[r'isVisible'] = null; } - if (this.isWatched != null) { - json[r'isWatched'] = this.isWatched; - } else { - // json[r'isWatched'] = null; - } if (this.name != null) { json[r'name'] = this.name; } else { @@ -117,7 +101,6 @@ class CreateLibraryDto { ? (json[r'importPaths'] as Iterable).cast().toList(growable: false) : const [], isVisible: mapValueOfType(json, r'isVisible'), - isWatched: mapValueOfType(json, r'isWatched'), name: mapValueOfType(json, r'name'), ownerId: mapValueOfType(json, r'ownerId')!, type: LibraryType.fromJson(json[r'type'])!, diff --git a/mobile/openapi/test/create_library_dto_test.dart b/mobile/openapi/test/create_library_dto_test.dart index 88911249e7..1dd77af251 100644 --- a/mobile/openapi/test/create_library_dto_test.dart +++ b/mobile/openapi/test/create_library_dto_test.dart @@ -31,11 +31,6 @@ void main() { // TODO }); - // bool isWatched - test('to test the property `isWatched`', () async { - // TODO - }); - // String name test('to test the property `name`', () async { // TODO diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 38df22f00e..a61a60eb84 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -8000,9 +8000,6 @@ "isVisible": { "type": "boolean" }, - "isWatched": { - "type": "boolean" - }, "name": { "type": "string" }, diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index 999fa23fa6..4d2cfa0415 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -461,7 +461,6 @@ export type CreateLibraryDto = { exclusionPatterns?: string[]; importPaths?: string[]; isVisible?: boolean; - isWatched?: boolean; name?: string; ownerId: string; "type": LibraryType; diff --git a/server/src/dtos/library.dto.ts b/server/src/dtos/library.dto.ts index 951012a852..b693d35adf 100644 --- a/server/src/dtos/library.dto.ts +++ b/server/src/dtos/library.dto.ts @@ -32,9 +32,6 @@ export class CreateLibraryDto { @ArrayUnique() @ArrayMaxSize(128) exclusionPatterns?: string[]; - - @ValidateBoolean({ optional: true }) - isWatched?: boolean; } export class UpdateLibraryDto { diff --git a/server/src/services/library.service.spec.ts b/server/src/services/library.service.spec.ts index df59d0c150..95e3655cb3 100644 --- a/server/src/services/library.service.spec.ts +++ b/server/src/services/library.service.spec.ts @@ -1058,14 +1058,6 @@ describe(LibraryService.name, () => { expect(libraryMock.create).not.toHaveBeenCalled(); }); - - it('should not create watched', async () => { - await expect( - sut.create({ ownerId: authStub.admin.user.id, type: LibraryType.UPLOAD, isWatched: true }), - ).rejects.toBeInstanceOf(BadRequestException); - - expect(storageMock.watch).not.toHaveBeenCalled(); - }); }); }); diff --git a/server/src/services/library.service.ts b/server/src/services/library.service.ts index d0e41da172..63066866fb 100644 --- a/server/src/services/library.service.ts +++ b/server/src/services/library.service.ts @@ -266,9 +266,6 @@ export class LibraryService extends EventEmitter { if (dto.exclusionPatterns && dto.exclusionPatterns.length > 0) { throw new BadRequestException('Upload libraries cannot have exclusion patterns'); } - if (dto.isWatched) { - throw new BadRequestException('Upload libraries cannot be watched'); - } break; } } diff --git a/web/src/routes/admin/library-management/+page.svelte b/web/src/routes/admin/library-management/+page.svelte index 1efc7f778f..723a6994bc 100644 --- a/web/src/routes/admin/library-management/+page.svelte +++ b/web/src/routes/admin/library-management/+page.svelte @@ -118,7 +118,9 @@ const handleCreate = async (ownerId: string) => { try { - const createdLibrary = await createLibrary({ createLibraryDto: { ownerId, type: LibraryType.External } }); + const createdLibrary = await createLibrary({ + createLibraryDto: { ownerId, type: LibraryType.External }, + }); notificationController.show({ message: `Created library: ${createdLibrary.name}`,