fix(notifications): only send one available notification for standard media

pull/633/head
sct 4 years ago
parent e0d9f891e7
commit fc6f7ccea5

@ -12,8 +12,11 @@ import notificationManager, { Notification } from '../lib/notifications';
@EventSubscriber() @EventSubscriber()
export class MediaSubscriber implements EntitySubscriberInterface { export class MediaSubscriber implements EntitySubscriberInterface {
private async notifyAvailableMovie(entity: Media) { private async notifyAvailableMovie(entity: Media, dbEntity?: Media) {
if (entity.status === MediaStatus.AVAILABLE) { if (
entity.status === MediaStatus.AVAILABLE &&
dbEntity?.status !== MediaStatus.AVAILABLE
) {
if (entity.mediaType === MediaType.MOVIE) { if (entity.mediaType === MediaType.MOVIE) {
const requestRepository = getRepository(MediaRequest); const requestRepository = getRepository(MediaRequest);
const relatedRequests = await requestRepository.find({ const relatedRequests = await requestRepository.find({
@ -100,7 +103,7 @@ export class MediaSubscriber implements EntitySubscriberInterface {
event.entity.mediaType === MediaType.MOVIE && event.entity.mediaType === MediaType.MOVIE &&
event.entity.status === MediaStatus.AVAILABLE event.entity.status === MediaStatus.AVAILABLE
) { ) {
this.notifyAvailableMovie(event.entity); this.notifyAvailableMovie(event.entity, event.databaseEntity);
} }
if ( if (

Loading…
Cancel
Save