Sistema de Notificaciones y Baja One-Click
This commit is contained in:
@@ -241,4 +241,61 @@ public class AdViewLog
|
||||
public int AdID { get; set; }
|
||||
public string IPAddress { get; set; } = string.Empty;
|
||||
public DateTime ViewDate { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Categorías de correo disponibles para preferencias de notificación.
|
||||
/// </summary>
|
||||
public static class NotificationCategory
|
||||
{
|
||||
public const string Sistema = "sistema"; // Avisos del sistema (vencimientos, pagos)
|
||||
public const string Marketing = "marketing"; // Boletines y promociones
|
||||
public const string Rendimiento = "rendimiento"; // Resumen semanal de visitas/favoritos
|
||||
public const string Mensajes = "mensajes"; // Recordatorio de mensajes no leídos
|
||||
|
||||
public static readonly string[] Todos = [Sistema, Marketing, Rendimiento, Mensajes];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preferencia de notificación por email de un usuario para una categoría específica.
|
||||
/// Por defecto el usuario recibe todos los correos; el registro solo se crea al DESACTIVAR.
|
||||
/// </summary>
|
||||
public class UserNotificationPreference
|
||||
{
|
||||
public int PreferenceID { get; set; }
|
||||
public int UserID { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
// Categoría: "sistema", "marketing", "rendimiento", "mensajes"
|
||||
public string Category { get; set; } = string.Empty;
|
||||
|
||||
// false = usuario optó por NO recibir esta categoría
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Token de baja firmado con HMAC-SHA256 para darse de baja sin login.
|
||||
/// El token incluye UserID + Category y es válido hasta ExpiresAt.
|
||||
/// </summary>
|
||||
public class UnsubscribeToken
|
||||
{
|
||||
public int TokenID { get; set; }
|
||||
public int UserID { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
// Categoría a la que aplica el token
|
||||
public string Category { get; set; } = string.Empty;
|
||||
|
||||
// Token opaco (GUID + HMAC) que va en el enlace del correo
|
||||
public string Token { get; set; } = string.Empty;
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Tokens de baja expiran a los 365 días (la URL del correo puede ser vieja)
|
||||
public DateTime ExpiresAt { get; set; } = DateTime.UtcNow.AddDays(365);
|
||||
|
||||
// true cuando ya fue utilizado para darse de baja
|
||||
public bool IsUsed { get; set; } = false;
|
||||
}
|
||||
Reference in New Issue
Block a user