fix(availability): 🐛 Fixed an issue where with 4k content, we could repeat notifications

pull/4541/head
tidusjar 3 years ago
parent 60cfd41f68
commit f9ebc1cc2e

@ -191,7 +191,7 @@ jobs:
with: with:
prerelease: true prerelease: true
generate_release_notes: true generate_release_notes: true
# body: ${{ needs.versioning.outputs.changelog }} body: ${{ needs.versioning.outputs.changelog }}
name: ${{ needs.versioning.outputs.tag }} name: ${{ needs.versioning.outputs.tag }}
tag_name: ${{ needs.versioning.outputs.tag }} tag_name: ${{ needs.versioning.outputs.tag }}
files: | files: |

@ -76,19 +76,23 @@ namespace Ombi.Schedule.Jobs.Emby
_log.LogInformation("We have found the request {0} on Emby, sending the notification", movie?.Title ?? string.Empty); _log.LogInformation("We have found the request {0} on Emby, sending the notification", movie?.Title ?? string.Empty);
if (has4kRequest && embyContent.Has4K) var notify = false;
if (has4kRequest && embyContent.Has4K && !movie.Available4K)
{ {
movie.Available4K = true; movie.Available4K = true;
movie.MarkedAsAvailable4K = DateTime.Now; movie.MarkedAsAvailable4K = DateTime.Now;
notify = true;
} }
// If we have a non-4k versison then mark as available // If we have a non-4k versison then mark as available
if (embyContent.Quality.HasValue()) if (embyContent.Quality.HasValue() && !movie.Available)
{ {
movie.Available = true; movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now; movie.MarkedAsAvailable = DateTime.Now;
notify = true;
} }
if (movie.Available) if (notify)
{ {
var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty; var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty;

@ -103,20 +103,24 @@ namespace Ombi.Schedule.Jobs.Jellyfin
_log.LogInformation("We have found the request {0} on Jellyfin, sending the notification", movie?.Title ?? string.Empty); _log.LogInformation("We have found the request {0} on Jellyfin, sending the notification", movie?.Title ?? string.Empty);
if (has4kRequest && jellyfinContent.Has4K) var notify = false;
if (has4kRequest && jellyfinContent.Has4K && !movie.Available4K)
{ {
movie.Available4K = true; movie.Available4K = true;
movie.MarkedAsAvailable4K = DateTime.Now; movie.MarkedAsAvailable4K = DateTime.Now;
notify = true;
} }
// If we have a non-4k versison then mark as available // If we have a non-4k versison then mark as available
if (jellyfinContent.Quality.HasValue()) if (jellyfinContent.Quality.HasValue() && !movie.Available)
{ {
movie.Available = true; movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now; movie.MarkedAsAvailable = DateTime.Now;
notify = true;
} }
if (movie.Available) if (notify)
{ {
var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty; var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty;

@ -206,29 +206,36 @@ namespace Ombi.Schedule.Jobs.Plex
_log.LogInformation($"[PAC] - Movie request {movie.Title} - {movie.Id} is now available, sending notification"); _log.LogInformation($"[PAC] - Movie request {movie.Title} - {movie.Id} is now available, sending notification");
if (has4kRequest && item.Has4K) var notify = false;
if (has4kRequest && item.Has4K && !movie.Available4K)
{ {
movie.Available4K = true; movie.Available4K = true;
movie.Approved4K = true; movie.Approved4K = true;
movie.MarkedAsAvailable4K = DateTime.Now; movie.MarkedAsAvailable4K = DateTime.Now;
await _movieRepo.SaveChangesAsync(); await _movieRepo.SaveChangesAsync();
notify = true;
} }
// If we have a non-4k versison then mark as available // If we have a non-4k versison then mark as available
if (item.Quality.HasValue()) if (item.Quality.HasValue() && !movie.Available)
{ {
movie.Available = true; movie.Available = true;
movie.Approved = true; movie.Approved = true;
movie.MarkedAsAvailable = DateTime.Now; movie.MarkedAsAvailable = DateTime.Now;
await _movieRepo.SaveChangesAsync(); await _movieRepo.SaveChangesAsync();
notify = true;
} }
if (notify)
{
itemsForAvailbility.Add(new AvailabilityModel itemsForAvailbility.Add(new AvailabilityModel
{ {
Id = movie.Id, Id = movie.Id,
RequestedUser = movie.RequestedUser != null ? movie.RequestedUser.Email : string.Empty RequestedUser = movie.RequestedUser != null ? movie.RequestedUser.Email : string.Empty
}); });
} }
}
foreach (var i in itemsForAvailbility.DistinctBy(x => x.Id)) foreach (var i in itemsForAvailbility.DistinctBy(x => x.Id))
{ {

@ -340,11 +340,11 @@ namespace Ombi.Schedule.Jobs.Plex
continue; continue;
} }
var hasSameKey = await Repo.GetByKey(movie.ratingKey); //var hasSameKey = await Repo.GetByKey(movie.ratingKey);
if (hasSameKey != null) //if (hasSameKey != null)
{ //{
await Repo.Delete(hasSameKey); // await Repo.Delete(hasSameKey);
} //}
Logger.LogDebug("Adding movie {0}", movie.title); Logger.LogDebug("Adding movie {0}", movie.title);
var guids = new List<string>(); var guids = new List<string>();

Loading…
Cancel
Save