mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): client emit events (#12606)
* refactor(server): client emit events * chore: test coverage
This commit is contained in:
parent
7b737786b3
commit
ba57646f9f
8 changed files with 142 additions and 20 deletions
|
|
@ -23,7 +23,7 @@ import { AssetEntity } from 'src/entities/asset.entity';
|
|||
import { Permission } from 'src/enum';
|
||||
import { IAccessRepository } from 'src/interfaces/access.interface';
|
||||
import { IAssetRepository } from 'src/interfaces/asset.interface';
|
||||
import { ClientEvent, IEventRepository } from 'src/interfaces/event.interface';
|
||||
import { IEventRepository } from 'src/interfaces/event.interface';
|
||||
import {
|
||||
IAssetDeleteJob,
|
||||
IJobRepository,
|
||||
|
|
@ -273,7 +273,8 @@ export class AssetService {
|
|||
if (!asset.libraryId) {
|
||||
await this.userRepository.updateUsage(asset.ownerId, -(asset.exifInfo?.fileSizeInByte || 0));
|
||||
}
|
||||
this.eventRepository.clientSend(ClientEvent.ASSET_DELETE, asset.ownerId, id);
|
||||
|
||||
await this.eventRepository.emit('asset.delete', { assetId: id, userId: asset.ownerId });
|
||||
|
||||
// delete the motion if it is not used by another asset
|
||||
if (asset.livePhotoVideoId) {
|
||||
|
|
@ -311,7 +312,7 @@ export class AssetService {
|
|||
);
|
||||
} else {
|
||||
await this.assetRepository.softDeleteAll(ids);
|
||||
this.eventRepository.clientSend(ClientEvent.ASSET_TRASH, auth.user.id, ids);
|
||||
await this.eventRepository.emit('assets.trash', { assetIds: ids, userId: auth.user.id });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue