From e8d287de8438833657f694736eb2937503290d3d Mon Sep 17 00:00:00 2001 From: Flaminel Date: Sat, 22 Feb 2025 03:02:51 +0200 Subject: [PATCH] fixed missing notification configuration --- .../Configuration/DownloadCleaner/DownloadCleanerConfig.cs | 4 ++-- code/Executable/DependencyInjection/MainDI.cs | 2 ++ .../Verticals/DownloadClient/QBittorrent/QBitService.cs | 5 +++-- .../Verticals/Notifications/Notifiarr/NotifiarrProxy.cs | 7 ++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/code/Common/Configuration/DownloadCleaner/DownloadCleanerConfig.cs b/code/Common/Configuration/DownloadCleaner/DownloadCleanerConfig.cs index 2ebe8ea..536899e 100644 --- a/code/Common/Configuration/DownloadCleaner/DownloadCleanerConfig.cs +++ b/code/Common/Configuration/DownloadCleaner/DownloadCleanerConfig.cs @@ -37,7 +37,7 @@ public sealed record DownloadCleanerConfig : IJobConfig 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()); @@ -54,7 +54,7 @@ public sealed record DownloadCleanerConfig : IJobConfig 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)) diff --git a/code/Executable/DependencyInjection/MainDI.cs b/code/Executable/DependencyInjection/MainDI.cs index 1631be3..e638ecc 100644 --- a/code/Executable/DependencyInjection/MainDI.cs +++ b/code/Executable/DependencyInjection/MainDI.cs @@ -27,6 +27,7 @@ public static class MainDI config.AddConsumer>(); config.AddConsumer>(); config.AddConsumer>(); + config.AddConsumer>(); config.UsingInMemory((context, cfg) => { @@ -36,6 +37,7 @@ public static class MainDI e.ConfigureConsumer>(context); e.ConfigureConsumer>(context); e.ConfigureConsumer>(context); + e.ConfigureConsumer>(context); e.ConcurrentMessageLimit = 1; e.PrefetchCount = 1; }); diff --git a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs index 0cb0a10..af0f5b3 100644 --- a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs @@ -404,9 +404,10 @@ public class QBitService : DownloadService, IQBitService continue; } - _logger.LogInformation("changing category for {name}", download.Name); - await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardLinksCategory); + + _logger.LogInformation("category changed for {name}", download.Name); + await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardLinksCategory); } } diff --git a/code/Infrastructure/Verticals/Notifications/Notifiarr/NotifiarrProxy.cs b/code/Infrastructure/Verticals/Notifications/Notifiarr/NotifiarrProxy.cs index edfc01a..0bb075a 100644 --- a/code/Infrastructure/Verticals/Notifications/Notifiarr/NotifiarrProxy.cs +++ b/code/Infrastructure/Verticals/Notifications/Notifiarr/NotifiarrProxy.cs @@ -1,5 +1,6 @@ using System.Text; using Common.Helpers; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; @@ -7,12 +8,14 @@ namespace Infrastructure.Verticals.Notifications.Notifiarr; public class NotifiarrProxy : INotifiarrProxy { + private readonly ILogger _logger; private readonly HttpClient _httpClient; private const string Url = "https://notifiarr.com/api/v1/notification/passthrough/"; - public NotifiarrProxy(IHttpClientFactory httpClientFactory) + public NotifiarrProxy(ILogger logger, IHttpClientFactory httpClientFactory) { + _logger = logger; _httpClient = httpClientFactory.CreateClient(Constants.HttpClientWithRetryName); } @@ -25,6 +28,8 @@ public class NotifiarrProxy : INotifiarrProxy ContractResolver = new CamelCasePropertyNamesContractResolver() }); + _logger.LogTrace("sending notification to Notifiarr: {content}", content); + using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"{Url}{config.ApiKey}"); request.Method = HttpMethod.Post; request.Content = new StringContent(content, Encoding.UTF8, "application/json");