mirror of
https://github.com/immich-app/immich.git
synced 2024-11-16 02:18:50 -07:00
fix(server): do not match live photos across libraries (#11952)
This commit is contained in:
parent
fd225e7462
commit
29d229c5ba
@ -16,6 +16,7 @@ export interface AssetStatsOptions {
|
|||||||
|
|
||||||
export interface LivePhotoSearchOptions {
|
export interface LivePhotoSearchOptions {
|
||||||
ownerId: string;
|
ownerId: string;
|
||||||
|
libraryId?: string | null;
|
||||||
livePhotoCID: string;
|
livePhotoCID: string;
|
||||||
otherAssetId: string;
|
otherAssetId: string;
|
||||||
type: AssetType;
|
type: AssetType;
|
||||||
|
@ -363,12 +363,13 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> {
|
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> {
|
||||||
const { ownerId, otherAssetId, livePhotoCID, type } = options;
|
const { ownerId, libraryId, otherAssetId, livePhotoCID, type } = options;
|
||||||
|
|
||||||
return this.repository.findOne({
|
return this.repository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: Not(otherAssetId),
|
id: Not(otherAssetId),
|
||||||
ownerId,
|
ownerId,
|
||||||
|
libraryId: libraryId || IsNull(),
|
||||||
type,
|
type,
|
||||||
exifInfo: {
|
exifInfo: {
|
||||||
livePhotoCID,
|
livePhotoCID,
|
||||||
|
@ -218,6 +218,29 @@ describe(MetadataService.name, () => {
|
|||||||
assetStub.livePhotoMotionAsset.id,
|
assetStub.livePhotoMotionAsset.id,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should search by libraryId', async () => {
|
||||||
|
assetMock.getByIds.mockResolvedValue([
|
||||||
|
{
|
||||||
|
...assetStub.livePhotoStillAsset,
|
||||||
|
libraryId: 'library-id',
|
||||||
|
exifInfo: { livePhotoCID: 'CID' } as ExifEntity,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
assetMock.findLivePhotoMatch.mockResolvedValue(null);
|
||||||
|
|
||||||
|
await expect(sut.handleLivePhotoLinking({ id: assetStub.livePhotoStillAsset.id })).resolves.toBe(
|
||||||
|
JobStatus.SKIPPED,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(assetMock.findLivePhotoMatch).toHaveBeenCalledWith({
|
||||||
|
ownerId: 'user-id',
|
||||||
|
otherAssetId: 'live-photo-still-asset',
|
||||||
|
livePhotoCID: 'CID',
|
||||||
|
libraryId: 'library-id',
|
||||||
|
type: 'VIDEO',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handleQueueMetadataExtraction', () => {
|
describe('handleQueueMetadataExtraction', () => {
|
||||||
|
@ -173,6 +173,7 @@ export class MetadataService {
|
|||||||
const match = await this.assetRepository.findLivePhotoMatch({
|
const match = await this.assetRepository.findLivePhotoMatch({
|
||||||
livePhotoCID: asset.exifInfo.livePhotoCID,
|
livePhotoCID: asset.exifInfo.livePhotoCID,
|
||||||
ownerId: asset.ownerId,
|
ownerId: asset.ownerId,
|
||||||
|
libraryId: asset.libraryId,
|
||||||
otherAssetId: asset.id,
|
otherAssetId: asset.id,
|
||||||
type: otherType,
|
type: otherType,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user