mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: add album create and delete events with websocket integration
This commit is contained in:
parent
cfbc24579d
commit
186cc11692
6 changed files with 122 additions and 5 deletions
|
|
@ -51,6 +51,8 @@ type EventMap = {
|
|||
// album events
|
||||
AlbumUpdate: [{ id: string; recipientId: string }];
|
||||
AlbumInvite: [{ id: string; userId: string }];
|
||||
AlbumDelete: [{ id: string; userId: string }];
|
||||
AlbumCreate: [{ id: string; userId: string }];
|
||||
|
||||
// asset events
|
||||
AssetTag: [{ assetId: string }];
|
||||
|
|
@ -110,6 +112,8 @@ export interface ClientEventMap {
|
|||
on_new_release: [ReleaseNotification];
|
||||
on_notification: [NotificationDto];
|
||||
on_session_delete: [string];
|
||||
on_album_delete: [string];
|
||||
on_album_create: [string];
|
||||
|
||||
AssetUploadReadyV1: [{ asset: SyncAssetV1; exif: SyncAssetExifV1 }];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ export class AlbumService extends BaseService {
|
|||
albumUsers,
|
||||
);
|
||||
|
||||
await this.eventRepository.emit('AlbumCreate', { id: album.id, userId: auth.user.id });
|
||||
|
||||
for (const { userId } of albumUsers) {
|
||||
await this.eventRepository.emit('AlbumInvite', { id: album.id, userId });
|
||||
}
|
||||
|
|
@ -154,6 +156,7 @@ export class AlbumService extends BaseService {
|
|||
async delete(auth: AuthDto, id: string): Promise<void> {
|
||||
await this.requireAccess({ auth, permission: Permission.AlbumDelete, ids: [id] });
|
||||
await this.albumRepository.delete(id);
|
||||
await this.eventRepository.emit('AlbumDelete', { id, userId: auth.user.id });
|
||||
}
|
||||
|
||||
async addAssets(auth: AuthDto, id: string, dto: BulkIdsDto): Promise<BulkIdResponseDto[]> {
|
||||
|
|
|
|||
|
|
@ -211,6 +211,18 @@ export class NotificationService extends BaseService {
|
|||
await this.jobRepository.queue({ name: JobName.NotifyAlbumInvite, data: { id, recipientId: userId } });
|
||||
}
|
||||
|
||||
@OnEvent({ name: 'AlbumDelete' })
|
||||
onAlbumDelete({ id, userId }: ArgOf<'AlbumDelete'>) {
|
||||
console.log(`Album ${id} deleted by user ${userId}`);
|
||||
this.eventRepository.clientSend('on_album_delete', userId, id);
|
||||
}
|
||||
|
||||
@OnEvent({ name: 'AlbumCreate' })
|
||||
onAlbumCreate({ id, userId }: ArgOf<'AlbumCreate'>) {
|
||||
console.log(`Album ${id} created by user ${userId}`);
|
||||
this.eventRepository.clientSend('on_album_create', userId, id);
|
||||
}
|
||||
|
||||
@OnEvent({ name: 'SessionDelete' })
|
||||
onSessionDelete({ sessionId }: ArgOf<'SessionDelete'>) {
|
||||
// after the response is sent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue