Skip to content

Commit

Permalink
fix(server): handle multiple hierarchical subjects (#12509)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 committed Sep 9, 2024
1 parent 7b2f98a commit b3ef5fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/src/services/metadata.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ describe(MetadataService.name, () => {

it('should extract hierarchy from HierarchicalSubject', async () => {
assetMock.getByIds.mockResolvedValue([assetStub.image]);
metadataMock.readTags.mockResolvedValue({ HierarchicalSubject: ['Parent|Child'] });
metadataMock.readTags.mockResolvedValue({ HierarchicalSubject: ['Parent|Child', 'TagA'] });
tagMock.upsertValue.mockResolvedValueOnce(tagStub.parent);
tagMock.upsertValue.mockResolvedValueOnce(tagStub.child);

Expand All @@ -465,6 +465,7 @@ describe(MetadataService.name, () => {
value: 'Parent/Child',
parent: tagStub.parent,
});
expect(tagMock.upsertValue).toHaveBeenNthCalledWith(3, { userId: 'user-id', value: 'TagA', parent: undefined });
});

it('should extract ignore / characters in a HierarchicalSubject tag', async () => {
Expand Down
4 changes: 2 additions & 2 deletions server/src/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ export class MetadataService {
}

private async applyTagList(asset: AssetEntity, exifTags: ImmichTags) {
const tags: unknown[] = [];
const tags: Array<string | number> = [];
if (exifTags.TagsList) {
tags.push(...exifTags.TagsList);
} else if (exifTags.HierarchicalSubject) {
tags.push(
exifTags.HierarchicalSubject.map((tag) =>
...exifTags.HierarchicalSubject.map((tag) =>
tag
// convert | to /
.replaceAll('/', '<PLACEHOLDER>')
Expand Down

0 comments on commit b3ef5fe

Please sign in to comment.