High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: keyword parsing (#12164)
Jason Rasmussend18bc7007a5f
diff --git a/server/src/services/metadata.service.spec.ts b/server/src/services/metadata.service.spec.tsindex 8f44962279..3e3e5e0db1 100644--- a/server/src/services/metadata.service.spec.ts+++ b/server/src/services/metadata.service.spec.ts@@ -408,6 +408,17 @@ describe(MetadataService.name, () => {expect(tagMock.upsertValue).toHaveBeenCalledWith({ userId: 'user-id', value: 'Parent', parent: undefined });});+ it('should extract tags from Keywords as a list with a number', async () => {+ assetMock.getByIds.mockResolvedValue([assetStub.image]);+ metadataMock.readTags.mockResolvedValue({ Keywords: ['Parent', 2024] as any[] });+ tagMock.upsertValue.mockResolvedValue(tagStub.parent);++ await sut.handleMetadataExtraction({ id: assetStub.image.id });++ expect(tagMock.upsertValue).toHaveBeenCalledWith({ userId: 'user-id', value: 'Parent', parent: undefined });+ expect(tagMock.upsertValue).toHaveBeenCalledWith({ userId: 'user-id', value: '2024', parent: undefined });+ });+it('should extract hierarchal tags from Keywords', async () => {assetMock.getByIds.mockResolvedValue([assetStub.image]);metadataMock.readTags.mockResolvedValue({ Keywords: 'Parent/Child' });diff --git a/server/src/services/metadata.service.ts b/server/src/services/metadata.service.tsindex 875414d84d..a0a8f9ebef 100644--- a/server/src/services/metadata.service.ts+++ b/server/src/services/metadata.service.ts@@ -352,22 +352,21 @@ export class MetadataService {}private async applyTagList(asset: AssetEntity, exifTags: ImmichTags) {- const tags: string[] = [];-+ const tags: unknown[] = [];if (exifTags.TagsList) {tags.push(...exifTags.TagsList);}if (exifTags.Keywords) {let keywords = exifTags.Keywords;- if (typeof keywords === 'string') {+ if (!Array.isArray(keywords)) {keywords = [keywords];}tags.push(...keywords);}if (tags.length > 0) {- const results = await upsertTags(this.tagRepository, { userId: asset.ownerId, tags });+ const results = await upsertTags(this.tagRepository, { userId: asset.ownerId, tags: tags.map(String) });const tagIds = results.map((tag) => tag.id);await this.tagRepository.upsertAssetTags({ assetId: asset.id, tagIds });}