removed ignored downloads path and config

This commit is contained in:
Flaminel
2025-06-07 02:05:51 +03:00
parent fd74455951
commit 8463b8b786
28 changed files with 150 additions and 768 deletions

View File

@@ -4,14 +4,10 @@ using Common.Configuration.DownloadCleaner;
using Common.Configuration.DownloadClient;
using Common.Configuration.DTOs.Arr;
using Common.Configuration.DTOs.ContentBlocker;
using Common.Configuration.DTOs.DownloadCleaner;
using Common.Configuration.DTOs.DownloadClient;
using Common.Configuration.DTOs.General;
using Common.Configuration.DTOs.IgnoredDownloads;
using Common.Configuration.DTOs.Notification;
using Common.Configuration.DTOs.QueueCleaner;
using Common.Configuration.General;
using Common.Configuration.IgnoredDownloads;
using Common.Configuration.Notification;
using Common.Configuration.QueueCleaner;
using Infrastructure.Configuration;
@@ -44,24 +40,14 @@ public class ConfigurationController : ControllerBase
public async Task<IActionResult> GetQueueCleanerConfig()
{
var config = await _configManager.GetConfigurationAsync<QueueCleanerConfig>();
var dto = config.Adapt<QueueCleanerConfigDto>();
return Ok(dto);
}
[HttpGet("content_blocker")]
public async Task<IActionResult> GetContentBlockerConfig()
{
var config = await _configManager.GetConfigurationAsync<ContentBlockerConfig>();
var dto = config.Adapt<ContentBlockerConfigDto>();
return Ok(dto);
return Ok(config);
}
[HttpGet("download_cleaner")]
public async Task<IActionResult> GetDownloadCleanerConfig()
{
var config = await _configManager.GetConfigurationAsync<DownloadCleanerConfig>();
var dto = config.Adapt<DownloadCleanerConfigDto>();
return Ok(dto);
return Ok(config);
}
[HttpGet("download_client")]
@@ -72,14 +58,6 @@ public class ConfigurationController : ControllerBase
return Ok(dto);
}
[HttpGet("ignored_downloads")]
public async Task<IActionResult> GetIgnoredDownloadsConfig()
{
var config = await _configManager.GetConfigurationAsync<IgnoredDownloadsConfig>();
var dto = config.Adapt<IgnoredDownloadsConfigDto>();
return Ok(dto);
}
[HttpGet("general")]
public async Task<IActionResult> GetGeneralConfig()
{
@@ -121,7 +99,7 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("queue_cleaner")]
public async Task<IActionResult> UpdateQueueCleanerConfig([FromBody] QueueCleanerConfigUpdateDto dto)
public async Task<IActionResult> UpdateQueueCleanerConfig([FromBody] QueueCleanerConfig dto)
{
// Get existing config
var config = await _configManager.GetConfigurationAsync<QueueCleanerConfig>();
@@ -202,7 +180,7 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("download_cleaner")]
public async Task<IActionResult> UpdateDownloadCleanerConfig([FromBody] DownloadCleanerConfigUpdateDto dto)
public async Task<IActionResult> UpdateDownloadCleanerConfig([FromBody] DownloadCleanerConfig dto)
{
// Get existing config
var config = await _configManager.GetConfigurationAsync<DownloadCleanerConfig>();
@@ -248,27 +226,8 @@ public class ConfigurationController : ControllerBase
return Ok(new { Message = "DownloadClient configuration updated successfully" });
}
[HttpPut("ignored_downloads")]
public async Task<IActionResult> UpdateIgnoredDownloadsConfig([FromBody] IgnoredDownloadsConfigUpdateDto dto)
{
// Get existing config
var config = await _configManager.GetConfigurationAsync<IgnoredDownloadsConfig>();
// Apply updates from DTO
dto.Adapt(config);
// Persist the configuration
var result = await _configManager.SaveConfigurationAsync(config);
if (!result)
{
return StatusCode(500, "Failed to save IgnoredDownloads configuration");
}
return Ok(new { Message = "IgnoredDownloads configuration updated successfully" });
}
[HttpPut("general")]
public async Task<IActionResult> UpdateGeneralConfig([FromBody] GeneralConfigUpdateDto dto)
public async Task<IActionResult> UpdateGeneralConfig([FromBody] GeneralConfig dto)
{
// Get existing config to preserve sensitive data
var config = await _configManager.GetConfigurationAsync<GeneralConfig>();

View File

@@ -1,121 +0,0 @@
using Common.Configuration.IgnoredDownloads;
using Infrastructure.Services;
using Microsoft.AspNetCore.Mvc;
namespace Executable.Controllers;
[ApiController]
[Route("api/[controller]")]
public class IgnoredDownloadsController : ControllerBase
{
private readonly ILogger<IgnoredDownloadsController> _logger;
private readonly IIgnoredDownloadsService _ignoredDownloadsService;
public IgnoredDownloadsController(
ILogger<IgnoredDownloadsController> logger,
IIgnoredDownloadsService ignoredDownloadsService)
{
_logger = logger;
_ignoredDownloadsService = ignoredDownloadsService;
}
/// <summary>
/// Get all ignored downloads
/// </summary>
[HttpGet]
public async Task<IActionResult> GetIgnoredDownloads()
{
try
{
var ignoredDownloads = await _ignoredDownloadsService.GetIgnoredDownloadsAsync();
return Ok(ignoredDownloads);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error retrieving ignored downloads");
return StatusCode(500, "An error occurred while retrieving ignored downloads");
}
}
/// <summary>
/// Add a new download ID to be ignored
/// </summary>
[HttpPost]
public async Task<IActionResult> AddIgnoredDownload([FromBody] string downloadId)
{
try
{
if (string.IsNullOrWhiteSpace(downloadId))
{
return BadRequest("Download ID cannot be empty");
}
var result = await _ignoredDownloadsService.AddIgnoredDownloadAsync(downloadId);
if (!result)
{
return StatusCode(500, "Failed to add download ID to ignored list");
}
_logger.LogInformation("Added download ID to ignored list: {DownloadId}", downloadId);
return Ok(new { Message = $"Download ID '{downloadId}' added to ignored list" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error adding download ID to ignored list");
return StatusCode(500, "An error occurred while adding download ID to ignored list");
}
}
/// <summary>
/// Remove a download ID from the ignored list
/// </summary>
[HttpDelete("{downloadId}")]
public async Task<IActionResult> RemoveIgnoredDownload(string downloadId)
{
try
{
if (string.IsNullOrWhiteSpace(downloadId))
{
return BadRequest("Download ID cannot be empty");
}
var result = await _ignoredDownloadsService.RemoveIgnoredDownloadAsync(downloadId);
if (!result)
{
return StatusCode(500, "Failed to remove download ID from ignored list");
}
_logger.LogInformation("Removed download ID from ignored list: {DownloadId}", downloadId);
return Ok(new { Message = $"Download ID '{downloadId}' removed from ignored list" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error removing download ID from ignored list");
return StatusCode(500, "An error occurred while removing download ID from ignored list");
}
}
/// <summary>
/// Clear all ignored downloads
/// </summary>
[HttpDelete]
public async Task<IActionResult> ClearIgnoredDownloads()
{
try
{
var result = await _ignoredDownloadsService.ClearIgnoredDownloadsAsync();
if (!result)
{
return StatusCode(500, "Failed to clear ignored downloads list");
}
_logger.LogInformation("Cleared all ignored downloads");
return Ok(new { Message = "All ignored downloads have been cleared" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error clearing ignored downloads list");
return StatusCode(500, "An error occurred while clearing ignored downloads list");
}
}
}