1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-07-15 00:57:36 +02:00

Fixed: Notify on Bulk Adds (Lists, Collections, Imports)

Closes #7351
This commit is contained in:
Qstick 2022-07-02 15:53:56 -05:00
parent a59928c66a
commit 69fcd8ec94
4 changed files with 27 additions and 5 deletions

View File

@ -5,11 +5,11 @@ namespace NzbDrone.Core.Movies.Events
{
public class MoviesImportedEvent : IEvent
{
public List<int> MovieIds { get; private set; }
public List<Movie> Movies { get; private set; }
public MoviesImportedEvent(List<int> movieIds)
public MoviesImportedEvent(List<Movie> movies)
{
MovieIds = movieIds;
Movies = movies;
}
}
}

View File

@ -23,7 +23,7 @@ public void Handle(MovieAddedEvent message)
public void Handle(MoviesImportedEvent message)
{
_commandQueueManager.PushMany(message.MovieIds.Select(s => new RefreshMovieCommand(new List<int> { s }, true)).ToList());
_commandQueueManager.PushMany(message.Movies.Select(s => new RefreshMovieCommand(new List<int> { s.Id }, true)).ToList());
}
}
}

View File

@ -100,7 +100,7 @@ public List<Movie> AddMovies(List<Movie> newMovies)
{
_movieRepository.InsertMany(newMovies);
_eventAggregator.PublishEvent(new MoviesImportedEvent(newMovies.Select(s => s.Id).ToList()));
_eventAggregator.PublishEvent(new MoviesImportedEvent(newMovies));
return newMovies;
}

View File

@ -20,6 +20,7 @@ public class NotificationService
IHandle<MovieImportedEvent>,
IHandle<MoviesDeletedEvent>,
IHandle<MovieAddedEvent>,
IHandle<MoviesImportedEvent>,
IHandle<MovieFileDeletedEvent>,
IHandle<HealthCheckFailedEvent>,
IHandle<UpdateInstalledEvent>,
@ -174,6 +175,27 @@ public void Handle(MovieAddedEvent message)
}
}
public void Handle(MoviesImportedEvent message)
{
foreach (var notification in _notificationFactory.OnMovieAddedEnabled())
{
try
{
foreach (var movie in message.Movies)
{
if (ShouldHandleMovie(notification.Definition, movie))
{
notification.OnMovieAdded(movie);
}
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Unable to send OnMovieAdded notification to: " + notification.Definition.Name);
}
}
}
public void Handle(MovieRenamedEvent message)
{
foreach (var notification in _notificationFactory.OnRenameEnabled())