mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Fixed duplicate notifications #3398
This commit is contained in:
parent
0e7cbe5c6b
commit
72403f21f6
4 changed files with 41 additions and 10 deletions
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
|
@ -36,6 +38,12 @@ namespace Ombi.Helpers
|
|||
return Scheduler;
|
||||
}
|
||||
|
||||
public static async Task<bool> IsJobRunnung(string jobName)
|
||||
{
|
||||
var running = await Scheduler.GetCurrentlyExecutingJobs();
|
||||
return running.Any(x => x.JobDetail.Key.Name.Equals(jobName, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public async Task AddJob<T>(string name, string group, string cronExpression, Dictionary<string, string> jobData = null)
|
||||
where T : IJob
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Ombi.Notifications.Agents
|
|||
|
||||
protected override bool ValidateConfiguration(TwilioSettings settings)
|
||||
{
|
||||
if (!settings.WhatsAppSettings?.Enabled ?? false)
|
||||
if (!settings?.WhatsAppSettings?.Enabled ?? false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -117,14 +117,29 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
|
||||
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
||||
{
|
||||
Logger.LogInformation("Kicking off Plex Availability Checker");
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
// Ensure it's not already running
|
||||
if (await OmbiQuartz.IsJobRunnung(nameof(IPlexAvailabilityChecker)))
|
||||
{
|
||||
Logger.LogInformation("Availability checker already running");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("Kicking off Plex Availability Checker");
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
}
|
||||
}
|
||||
|
||||
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
||||
{
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
// Ensure it's not already running
|
||||
if (await OmbiQuartz.IsJobRunnung(nameof(IPlexAvailabilityChecker)))
|
||||
{
|
||||
Logger.LogInformation("Availability checker already running");
|
||||
}
|
||||
else
|
||||
{
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
}
|
||||
}
|
||||
Logger.LogInformation("Finished Plex Content Cacher, with processed content: {0}, episodes: {1}. Recently Added Scan: {2}", processedContent?.Content?.Count() ?? 0, processedContent?.Episodes?.Count() ?? 0, recentlyAddedSearch);
|
||||
|
||||
|
@ -183,7 +198,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
{
|
||||
Logger.LogDebug("Found some episodes, this must be a recently added sync");
|
||||
var count = 0;
|
||||
foreach (var epInfo in content.Metadata ?? new Metadata[]{})
|
||||
foreach (var epInfo in content.Metadata ?? new Metadata[] { })
|
||||
{
|
||||
count++;
|
||||
var grandParentKey = epInfo.grandparentRatingKey;
|
||||
|
@ -391,7 +406,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
await Repo.Delete(existingKey);
|
||||
existingKey = null;
|
||||
}
|
||||
else if(existingContent == null)
|
||||
else if (existingContent == null)
|
||||
{
|
||||
existingContent = await Repo.GetFirstContentByCustom(x => x.Key == show.ratingKey);
|
||||
}
|
||||
|
@ -509,7 +524,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
// But it does not contain the `guid` property that we need to pull out thetvdb id...
|
||||
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
|
||||
show.ratingKey);
|
||||
|
||||
|
||||
var item = new PlexServerContent
|
||||
{
|
||||
AddedAt = DateTime.Now,
|
||||
|
|
|
@ -64,7 +64,15 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
// Ensure it's not already running
|
||||
if (await OmbiQuartz.IsJobRunnung(nameof(IPlexAvailabilityChecker)))
|
||||
{
|
||||
_log.LogInformation("Availability checker already running");
|
||||
}
|
||||
else
|
||||
{
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
}
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Finished");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue