combine arr configs #1

This commit is contained in:
Flaminel
2025-06-15 21:15:50 +03:00
parent 62eee94497
commit bf37668dcb
74 changed files with 486 additions and 703 deletions

View File

@@ -0,0 +1,23 @@
namespace Data.Models.Configuration.Notification;
public sealed record AppriseConfig : NotificationConfig
{
public Uri? Url { get; init; }
public string? Key { get; init; }
public override bool IsValid()
{
if (Url is null)
{
return false;
}
if (string.IsNullOrEmpty(Key?.Trim()))
{
return false;
}
return true;
}
}

View File

@@ -0,0 +1,23 @@
namespace Data.Models.Configuration.Notification;
public sealed record NotifiarrConfig : NotificationConfig
{
public string? ApiKey { get; init; }
public string? ChannelId { get; init; }
public override bool IsValid()
{
if (string.IsNullOrEmpty(ApiKey?.Trim()))
{
return false;
}
if (string.IsNullOrEmpty(ChannelId?.Trim()))
{
return false;
}
return true;
}
}

View File

@@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Data.Models.Configuration.Notification;
public abstract record NotificationConfig
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; init; } = Guid.NewGuid();
public bool OnFailedImportStrike { get; init; }
public bool OnStalledStrike { get; init; }
public bool OnSlowStrike { get; init; }
public bool OnQueueItemDeleted { get; init; }
public bool OnDownloadCleaned { get; init; }
public bool OnCategoryChanged { get; init; }
public bool IsEnabled =>
OnFailedImportStrike ||
OnStalledStrike ||
OnSlowStrike ||
OnQueueItemDeleted ||
OnDownloadCleaned ||
OnCategoryChanged;
public abstract bool IsValid();
}