fixed missing notification configuration

This commit is contained in:
Flaminel
2025-02-22 03:02:51 +02:00
parent c65c85a0c5
commit e8d287de84
4 changed files with 13 additions and 5 deletions
@@ -37,7 +37,7 @@ public sealed record DownloadCleanerConfig : IJobConfig
if (Categories?.GroupBy(x => x.Name).Any(x => x.Count() > 1) is true) if (Categories?.GroupBy(x => x.Name).Any(x => x.Count() > 1) is true)
{ {
throw new ValidationException("duplicated categories found"); throw new ValidationException("duplicated clean categories found");
} }
Categories?.ForEach(x => x.Validate()); Categories?.ForEach(x => x.Validate());
@@ -54,7 +54,7 @@ public sealed record DownloadCleanerConfig : IJobConfig
if (NoHardLinksCategories.Contains(NoHardLinksCategory)) if (NoHardLinksCategories.Contains(NoHardLinksCategory))
{ {
throw new ValidationException("NO_HARDLINKS_CATEGORY is present in the list of filtered categories"); throw new ValidationException("NO_HARDLINKS_CATEGORY is present in NO_HARDLINKS_CATEGORIES");
} }
if (NoHardLinksCategories.Any(string.IsNullOrEmpty)) if (NoHardLinksCategories.Any(string.IsNullOrEmpty))
@@ -27,6 +27,7 @@ public static class MainDI
config.AddConsumer<NotificationConsumer<StalledStrikeNotification>>(); config.AddConsumer<NotificationConsumer<StalledStrikeNotification>>();
config.AddConsumer<NotificationConsumer<QueueItemDeletedNotification>>(); config.AddConsumer<NotificationConsumer<QueueItemDeletedNotification>>();
config.AddConsumer<NotificationConsumer<DownloadCleanedNotification>>(); config.AddConsumer<NotificationConsumer<DownloadCleanedNotification>>();
config.AddConsumer<NotificationConsumer<CategoryChangedNotification>>();
config.UsingInMemory((context, cfg) => config.UsingInMemory((context, cfg) =>
{ {
@@ -36,6 +37,7 @@ public static class MainDI
e.ConfigureConsumer<NotificationConsumer<StalledStrikeNotification>>(context); e.ConfigureConsumer<NotificationConsumer<StalledStrikeNotification>>(context);
e.ConfigureConsumer<NotificationConsumer<QueueItemDeletedNotification>>(context); e.ConfigureConsumer<NotificationConsumer<QueueItemDeletedNotification>>(context);
e.ConfigureConsumer<NotificationConsumer<DownloadCleanedNotification>>(context); e.ConfigureConsumer<NotificationConsumer<DownloadCleanedNotification>>(context);
e.ConfigureConsumer<NotificationConsumer<CategoryChangedNotification>>(context);
e.ConcurrentMessageLimit = 1; e.ConcurrentMessageLimit = 1;
e.PrefetchCount = 1; e.PrefetchCount = 1;
}); });
@@ -404,9 +404,10 @@ public class QBitService : DownloadService, IQBitService
continue; continue;
} }
_logger.LogInformation("changing category for {name}", download.Name);
await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardLinksCategory); await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardLinksCategory);
_logger.LogInformation("category changed for {name}", download.Name);
await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardLinksCategory); await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardLinksCategory);
} }
} }
@@ -1,5 +1,6 @@
using System.Text; using System.Text;
using Common.Helpers; using Common.Helpers;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -7,12 +8,14 @@ namespace Infrastructure.Verticals.Notifications.Notifiarr;
public class NotifiarrProxy : INotifiarrProxy public class NotifiarrProxy : INotifiarrProxy
{ {
private readonly ILogger<NotifiarrProxy> _logger;
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
private const string Url = "https://notifiarr.com/api/v1/notification/passthrough/"; private const string Url = "https://notifiarr.com/api/v1/notification/passthrough/";
public NotifiarrProxy(IHttpClientFactory httpClientFactory) public NotifiarrProxy(ILogger<NotifiarrProxy> logger, IHttpClientFactory httpClientFactory)
{ {
_logger = logger;
_httpClient = httpClientFactory.CreateClient(Constants.HttpClientWithRetryName); _httpClient = httpClientFactory.CreateClient(Constants.HttpClientWithRetryName);
} }
@@ -25,6 +28,8 @@ public class NotifiarrProxy : INotifiarrProxy
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
_logger.LogTrace("sending notification to Notifiarr: {content}", content);
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"{Url}{config.ApiKey}"); using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"{Url}{config.ApiKey}");
request.Method = HttpMethod.Post; request.Method = HttpMethod.Post;
request.Content = new StringContent(content, Encoding.UTF8, "application/json"); request.Content = new StringContent(content, Encoding.UTF8, "application/json");