Files
Heimdall/src/Heimdall.Domain/Entities/UserNotificationConfig.cs
T

59 lines
1.7 KiB
C#
Raw Normal View History

using Heimdall.Domain.Enums;
using Heimdall.Domain.Primitives;
namespace Heimdall.Domain.Entities;
/// <summary>
/// Per-user notification preferences including channel configuration,
/// language, digest schedule, and subscribed event types.
/// </summary>
public class UserNotificationConfig : Entity<Guid>, IAuditableEntity
{
public Guid UserId { get; private set; }
public bool EmailEnabled { get; private set; }
public string? EmailAddress { get; private set; }
public bool NtfyEnabled { get; private set; }
public string? NtfyUrl { get; private set; }
public string Language { get; private set; } = "fr";
public bool DailyDigest { get; private set; }
public bool WeeklyDigest { get; private set; }
public string? SubscribedEventsJson { get; private set; } // JSON array of EventType values
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
private UserNotificationConfig() { } // EF Core
public UserNotificationConfig(Guid userId)
: base(Guid.NewGuid())
{
UserId = userId;
}
public void UpdateEmail(string? emailAddress, bool enabled)
{
EmailAddress = emailAddress;
EmailEnabled = enabled;
}
public void UpdateNtfy(string? url, bool enabled)
{
NtfyUrl = url;
NtfyEnabled = enabled;
}
public void UpdateDigests(bool daily, bool weekly)
{
DailyDigest = daily;
WeeklyDigest = weekly;
}
public void SetSubscribedEvents(string? subscribedEventsJson)
{
SubscribedEventsJson = subscribedEventsJson;
}
public void SetLanguage(string language)
{
Language = language;
}
}