156 lines
5.3 KiB
C#
156 lines
5.3 KiB
C#
namespace MiaoJiZhang.Domain.Entities;
|
|
|
|
public static class PushProviders
|
|
{
|
|
public const string Huawei = "huawei";
|
|
public const string Honor = "honor";
|
|
public const string Xiaomi = "xiaomi";
|
|
public const string Oppo = "oppo";
|
|
public const string Vivo = "vivo";
|
|
public const string Meizu = "meizu";
|
|
|
|
public static readonly IReadOnlySet<string> All = new HashSet<string>(
|
|
[Huawei, Honor, Xiaomi, Oppo, Vivo, Meizu],
|
|
StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static class PushCategories
|
|
{
|
|
public const string System = "system";
|
|
public const string Budget = "budget";
|
|
public const string Operations = "operations";
|
|
|
|
public static readonly IReadOnlySet<string> All = new HashSet<string>(
|
|
[System, Budget, Operations],
|
|
StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static class PushActions
|
|
{
|
|
public const string None = "none";
|
|
public const string Home = "home";
|
|
public const string Budget = "budget";
|
|
public const string Update = "update";
|
|
|
|
public static readonly IReadOnlySet<string> All = new HashSet<string>(
|
|
[None, Home, Budget, Update],
|
|
StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static class PushMessageStates
|
|
{
|
|
public const string Draft = "draft";
|
|
public const string Scheduled = "scheduled";
|
|
public const string Queued = "queued";
|
|
public const string Sending = "sending";
|
|
public const string Completed = "completed";
|
|
public const string PartiallyFailed = "partially_failed";
|
|
public const string Cancelled = "cancelled";
|
|
}
|
|
|
|
public static class PushDeliveryStates
|
|
{
|
|
public const string Queued = "queued";
|
|
public const string Sending = "sending";
|
|
public const string Accepted = "accepted";
|
|
public const string Failed = "failed";
|
|
public const string Skipped = "skipped";
|
|
}
|
|
|
|
public class PushDevice
|
|
{
|
|
public long Id { get; set; }
|
|
public long UserId { get; set; }
|
|
public User User { get; set; } = null!;
|
|
public string InstallationId { get; set; } = null!;
|
|
public string Provider { get; set; } = null!;
|
|
public string TokenCiphertext { get; set; } = null!;
|
|
public string TokenHash { get; set; } = null!;
|
|
public string UnbindTokenHash { get; set; } = null!;
|
|
public string PackageName { get; set; } = null!;
|
|
public string Flavor { get; set; } = null!;
|
|
public string AppVersion { get; set; } = null!;
|
|
public int VersionCode { get; set; }
|
|
public bool NotificationsAllowed { get; set; }
|
|
public bool IsActive { get; set; } = true;
|
|
public string? DisabledReason { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
public DateTime LastSeenAt { get; set; }
|
|
|
|
public List<PushDelivery> Deliveries { get; set; } = [];
|
|
}
|
|
|
|
public class UserPushPreference
|
|
{
|
|
public long Id { get; set; }
|
|
public long UserId { get; set; }
|
|
public User User { get; set; } = null!;
|
|
public string Category { get; set; } = null!;
|
|
public bool IsEnabled { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class PushMessage
|
|
{
|
|
public long Id { get; set; }
|
|
public string PublicId { get; set; } = null!;
|
|
public string Source { get; set; } = null!;
|
|
public string State { get; set; } = PushMessageStates.Draft;
|
|
public string Category { get; set; } = null!;
|
|
public string Title { get; set; } = null!;
|
|
public string Body { get; set; } = null!;
|
|
public string Action { get; set; } = PushActions.None;
|
|
public string? EntityId { get; set; }
|
|
public long? TargetUserId { get; set; }
|
|
public string Flavor { get; set; } = "production";
|
|
public string? ProviderFilter { get; set; }
|
|
public int? MinVersionCode { get; set; }
|
|
public int? MaxVersionCode { get; set; }
|
|
public int TtlSeconds { get; set; }
|
|
public bool IsTest { get; set; }
|
|
public long? TestDeviceId { get; set; }
|
|
public DateTime? ScheduledAt { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
public DateTime? StartedAt { get; set; }
|
|
public DateTime? CompletedAt { get; set; }
|
|
public DateTime? CancelledAt { get; set; }
|
|
|
|
public List<PushDelivery> Deliveries { get; set; } = [];
|
|
}
|
|
|
|
public class PushDelivery
|
|
{
|
|
public long Id { get; set; }
|
|
public long PushMessageId { get; set; }
|
|
public PushMessage PushMessage { get; set; } = null!;
|
|
public long PushDeviceId { get; set; }
|
|
public PushDevice PushDevice { get; set; } = null!;
|
|
public long UserId { get; set; }
|
|
public string Provider { get; set; } = null!;
|
|
public string State { get; set; } = PushDeliveryStates.Queued;
|
|
public int AttemptCount { get; set; }
|
|
public DateTime NextAttemptAt { get; set; }
|
|
public string? LeaseId { get; set; }
|
|
public DateTime? LeaseExpiresAt { get; set; }
|
|
public string? ProviderMessageId { get; set; }
|
|
public string? ErrorCode { get; set; }
|
|
public string? ErrorMessage { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime UpdatedAt { get; set; }
|
|
public DateTime? AcceptedAt { get; set; }
|
|
}
|
|
|
|
public class BudgetNotificationReceipt
|
|
{
|
|
public long Id { get; set; }
|
|
public long UserId { get; set; }
|
|
public User User { get; set; } = null!;
|
|
public long BudgetId { get; set; }
|
|
public Budget Budget { get; set; } = null!;
|
|
public int Period { get; set; }
|
|
public int Threshold { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
}
|