Add proposal workflow and voting API
This commit is contained in:
1 parent
9ca23a2c15
commit
1ff4a0a814
17 files changed
+796
-83
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using Helpdesk.Domain.Issues;
|
||||
using Helpdesk.Domain.Proposals;
|
||||
|
||||
namespace Helpdesk.Domain.Notifications;
|
||||
|
||||
public enum NotificationType { IssueCreated, IssueAssigned, IssueStatusChanged, IssueCommentAdded, IssueReopened, ProposalStatusChanged }
|
||||
public enum DeliveryChannel { Email, Push }
|
||||
public enum DeliveryStatus { Pending, Skipped }
|
||||
|
||||
public sealed class Notification : IHasCreatedAt
|
||||
{
|
||||
private Notification() { }
|
||||
|
||||
public Notification(Issue issue, int userId, NotificationType type, string title, string message)
|
||||
: this(userId, type, title, message)
|
||||
{
|
||||
Issue = issue;
|
||||
}
|
||||
|
||||
public Notification(Proposal proposal, int userId, string title)
|
||||
: this(userId, NotificationType.ProposalStatusChanged, title, proposal.Title)
|
||||
{
|
||||
ProposalId = proposal.Id;
|
||||
}
|
||||
|
||||
private Notification(int userId, NotificationType type, string title, string message)
|
||||
{
|
||||
UserId = userId;
|
||||
Type = type;
|
||||
Title = title;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public int Id { get; private set; }
|
||||
public int? IssueId { get; private set; }
|
||||
public int? ProposalId { get; private set; }
|
||||
public Issue? Issue { get; private set; }
|
||||
public int UserId { get; private set; }
|
||||
public NotificationType Type { get; private set; }
|
||||
public string Title { get; private set; } = null!;
|
||||
public string Message { get; private set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime? ReadAt { get; private set; }
|
||||
}
|
||||
|
||||
public sealed class NotificationDelivery(
|
||||
Notification notification, DeliveryChannel channel, bool enabled, DateTime now)
|
||||
{
|
||||
private NotificationDelivery() : this(null!, default, false, default) { }
|
||||
|
||||
public int Id { get; private set; }
|
||||
public int NotificationId { get; private set; }
|
||||
public Notification Notification { get; private set; } = notification;
|
||||
public DeliveryChannel Channel { get; private set; } = channel;
|
||||
public DeliveryStatus Status { get; private set; } = enabled ? DeliveryStatus.Pending : DeliveryStatus.Skipped;
|
||||
public DateTime? NextAttemptAt { get; private set; } = enabled ? now : null;
|
||||
}
|
||||
|
||||
public sealed class PushDevice
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int UserId { get; private set; }
|
||||
}
|
||||
Reference in new issue
Block a user