fix: keyword parsing (#12164)

This commit is contained in:
Jason Rasmussen
2024-08-30 17:33:42 -04:00
committed by GitHub
parent 4cc11efd04
commit d18bc7007a
2 changed files with 14 additions and 4 deletions
+3 -4
View File
@@ -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 });
}