|
|
|
|
@ -142,56 +142,26 @@ export class AssetService extends BaseService {
|
|
|
|
|
} = dto;
|
|
|
|
|
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
|
|
|
|
|
|
|
|
|
const assetDto = { isFavorite, visibility, duplicateId };
|
|
|
|
|
const assetDto = _.omitBy({ isFavorite, visibility, duplicateId }, _.isUndefined);
|
|
|
|
|
const exifDto = _.omitBy({ latitude, longitude, rating, description, dateTimeOriginal }, _.isUndefined);
|
|
|
|
|
|
|
|
|
|
const isExifChanged = Object.keys(exifDto).length > 0;
|
|
|
|
|
if (isExifChanged) {
|
|
|
|
|
if (Object.keys(exifDto).length > 0) {
|
|
|
|
|
await this.assetRepository.updateAllExif(ids, exifDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const assets =
|
|
|
|
|
(dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined
|
|
|
|
|
? await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone)
|
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
|
|
const dateTimesWithTimezone = assets
|
|
|
|
|
? assets.map((asset) => {
|
|
|
|
|
const isoString = asset.dateTimeOriginal?.toISOString();
|
|
|
|
|
let dateTime = isoString ? DateTime.fromISO(isoString) : null;
|
|
|
|
|
|
|
|
|
|
if (dateTime && asset.timeZone) {
|
|
|
|
|
dateTime = dateTime.setZone(asset.timeZone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
assetId: asset.assetId,
|
|
|
|
|
dateTimeOriginal: dateTime?.toISO() ?? null,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
: ids.map((id) => ({ assetId: id, dateTimeOriginal }));
|
|
|
|
|
|
|
|
|
|
if (dateTimesWithTimezone.length > 0) {
|
|
|
|
|
await this.jobRepository.queueAll(
|
|
|
|
|
dateTimesWithTimezone.map(({ assetId: id, dateTimeOriginal }) => ({
|
|
|
|
|
name: JobName.SidecarWrite,
|
|
|
|
|
data: {
|
|
|
|
|
...exifDto,
|
|
|
|
|
id,
|
|
|
|
|
dateTimeOriginal: dateTimeOriginal ?? undefined,
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
);
|
|
|
|
|
if ((dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined) {
|
|
|
|
|
await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isAssetChanged = Object.values(assetDto).some((v) => v !== undefined);
|
|
|
|
|
if (isAssetChanged) {
|
|
|
|
|
if (Object.keys(assetDto).length > 0) {
|
|
|
|
|
await this.assetRepository.updateAll(ids, assetDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (visibility === AssetVisibility.Locked) {
|
|
|
|
|
await this.albumRepository.removeAssetsFromAll(ids);
|
|
|
|
|
}
|
|
|
|
|
if (visibility === AssetVisibility.Locked) {
|
|
|
|
|
await this.albumRepository.removeAssetsFromAll(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.jobRepository.queueAll(ids.map((id) => ({ name: JobName.SidecarWrite, data: { id } })));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async copy(
|
|
|
|
|
|