mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -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 System.Threading.Tasks;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using Quartz.Impl;
|
using Quartz.Impl;
|
||||||
|
@ -36,6 +38,12 @@ namespace Ombi.Helpers
|
||||||
return Scheduler;
|
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)
|
public async Task AddJob<T>(string name, string group, string cronExpression, Dictionary<string, string> jobData = null)
|
||||||
where T : IJob
|
where T : IJob
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Ombi.Notifications.Agents
|
||||||
|
|
||||||
protected override bool ValidateConfiguration(TwilioSettings settings)
|
protected override bool ValidateConfiguration(TwilioSettings settings)
|
||||||
{
|
{
|
||||||
if (!settings.WhatsAppSettings?.Enabled ?? false)
|
if (!settings?.WhatsAppSettings?.Enabled ?? false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,16 +116,31 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
||||||
|
{
|
||||||
|
// 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");
|
Logger.LogInformation("Kicking off Plex Availability Checker");
|
||||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
|
||||||
{
|
{
|
||||||
|
// 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");
|
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);
|
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);
|
||||||
|
|
||||||
await Notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
await Notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||||
|
@ -183,7 +198,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
Logger.LogDebug("Found some episodes, this must be a recently added sync");
|
Logger.LogDebug("Found some episodes, this must be a recently added sync");
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var epInfo in content.Metadata ?? new Metadata[]{})
|
foreach (var epInfo in content.Metadata ?? new Metadata[] { })
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
var grandParentKey = epInfo.grandparentRatingKey;
|
var grandParentKey = epInfo.grandparentRatingKey;
|
||||||
|
@ -391,7 +406,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
await Repo.Delete(existingKey);
|
await Repo.Delete(existingKey);
|
||||||
existingKey = null;
|
existingKey = null;
|
||||||
}
|
}
|
||||||
else if(existingContent == null)
|
else if (existingContent == null)
|
||||||
{
|
{
|
||||||
existingContent = await Repo.GetFirstContentByCustom(x => x.Key == show.ratingKey);
|
existingContent = await Repo.GetFirstContentByCustom(x => x.Key == show.ratingKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,15 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
}
|
}
|
||||||
|
|
||||||
await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
|
await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
|
||||||
|
// 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 OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||||
|
}
|
||||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Finished");
|
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Finished");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue