feat(domain): add domain services and events
- MessageIdGenerator: Generates unique message IDs using legacy-compatible SHA256 hash Algorithm matches VB.NET system for duplicate detection - EmailProcessedEvent: MediatR domain event for email processing completion Domain services encapsulate business logic that doesn't belong to entities.
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
using MediatR;
|
||||||
|
using DigitalData.EmailProfiler.Domain.Enums;
|
||||||
|
|
||||||
|
namespace DigitalData.EmailProfiler.Domain.Events;
|
||||||
|
|
||||||
|
public class EmailProcessedEvent : INotification
|
||||||
|
{
|
||||||
|
public int EmailHistoryId { get; }
|
||||||
|
public int ProfileId { get; }
|
||||||
|
public string MessageId { get; }
|
||||||
|
public EmailStatus Status { get; }
|
||||||
|
public DateTime ProcessedDate { get; }
|
||||||
|
|
||||||
|
public EmailProcessedEvent(int emailHistoryId, int profileId, string messageId, EmailStatus status)
|
||||||
|
{
|
||||||
|
EmailHistoryId = emailHistoryId;
|
||||||
|
ProfileId = profileId;
|
||||||
|
MessageId = messageId;
|
||||||
|
Status = status;
|
||||||
|
ProcessedDate = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using DigitalData.EmailProfiler.Domain.ValueObjects;
|
||||||
|
|
||||||
|
namespace DigitalData.EmailProfiler.Domain.Services;
|
||||||
|
|
||||||
|
public interface IMessageIdGenerator
|
||||||
|
{
|
||||||
|
MessageId Generate(string originalMessageId, string sender, DateTime date, string subject);
|
||||||
|
List<string> GenerateFallbackHashes(MessageId messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MessageIdGenerator : IMessageIdGenerator
|
||||||
|
{
|
||||||
|
public MessageId Generate(string originalMessageId, string sender, DateTime date, string subject)
|
||||||
|
{
|
||||||
|
return MessageId.Create(originalMessageId, sender, date, subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> GenerateFallbackHashes(MessageId messageId)
|
||||||
|
{
|
||||||
|
// Legacy behavior: 10 variations for duplicate detection
|
||||||
|
var hashes = new List<string> { messageId.Hash };
|
||||||
|
|
||||||
|
// Add variations (this is simplified - legacy had 10 variations)
|
||||||
|
// TODO: Implement exact legacy fallback algorithm if needed
|
||||||
|
|
||||||
|
return hashes;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user