Skip to content

Commit

Permalink
fix(notifications): only send one available notification for standard…
Browse files Browse the repository at this point in the history
… media
  • Loading branch information
sct committed Jan 11, 2021
1 parent e0d9f89 commit fc6f7cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/subscriber/MediaSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit fc6f7cc

Please sign in to comment.