refactor(server): client emit events (#12606)

* refactor(server): client emit events

* chore: test coverage
This commit is contained in:
Jason Rasmussen 2024-09-12 14:12:39 -04:00 committed by GitHub
parent 7b737786b3
commit ba57646f9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 142 additions and 20 deletions

View file

@ -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 });
}
}