From fc6f7ccea586165a30022b6d5554911c66ece6df Mon Sep 17 00:00:00 2001 From: sct Date: Mon, 11 Jan 2021 15:45:28 +0000 Subject: [PATCH] fix(notifications): only send one available notification for standard media --- server/subscriber/MediaSubscriber.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/subscriber/MediaSubscriber.ts b/server/subscriber/MediaSubscriber.ts index fe826284c..7a8b9edf9 100644 --- a/server/subscriber/MediaSubscriber.ts +++ b/server/subscriber/MediaSubscriber.ts @@ -12,8 +12,11 @@ import notificationManager, { Notification } from '../lib/notifications'; @EventSubscriber() export class MediaSubscriber implements EntitySubscriberInterface { - private async notifyAvailableMovie(entity: Media) { - if (entity.status === MediaStatus.AVAILABLE) { + private async notifyAvailableMovie(entity: Media, dbEntity?: Media) { + if ( + entity.status === MediaStatus.AVAILABLE && + dbEntity?.status !== MediaStatus.AVAILABLE + ) { if (entity.mediaType === MediaType.MOVIE) { const requestRepository = getRepository(MediaRequest); const relatedRequests = await requestRepository.find({ @@ -100,7 +103,7 @@ export class MediaSubscriber implements EntitySubscriberInterface { event.entity.mediaType === MediaType.MOVIE && event.entity.status === MediaStatus.AVAILABLE ) { - this.notifyAvailableMovie(event.entity); + this.notifyAvailableMovie(event.entity, event.databaseEntity); } if (