Refactor: Replace EmailAttachmentContext with DTO
Replaced `EmailAttachmentContext` with `EmailAttachmentDto` across the codebase to align with the updated DTO naming convention. - Renamed `EmailAttachmentContext` to `EmailAttachmentDto`. - Updated property types, method signatures, and return types to use `EmailAttachmentDto`. - Modified XML documentation references to reflect the new class name. - Updated `ReceivedEmailContext` to `ReceivedEmailDto` and adjusted related methods and properties. - Refactored `FetchEmailsAsync` methods and handlers to use `ReceivedEmailDto`. - Adjusted `BuildAttachmentsAsync` and attachment handling logic in `EmailController` and `LimilabsImapEmailService`. This refactor ensures consistency and improves code clarity while maintaining functionality.
This commit is contained in:
@@ -111,7 +111,7 @@ public class LimilabsEmailService(
|
||||
return message.ToString();
|
||||
}
|
||||
|
||||
private static void AddAttachments(MailBuilder builder, IEnumerable<EmailAttachmentContext> attachments)
|
||||
private static void AddAttachments(MailBuilder builder, IEnumerable<EmailAttachmentDto> attachments)
|
||||
{
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public class LimilabsImapEmailService(
|
||||
}
|
||||
|
||||
// Public API
|
||||
public async Task<IEnumerable<ReceivedEmailContext>> FetchEmailsAsync(
|
||||
public async Task<IEnumerable<ReceivedEmailDto>> FetchEmailsAsync(
|
||||
EmailAccountDto account,
|
||||
MailSearchFilter filter,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -60,7 +60,7 @@ public class LimilabsImapEmailService(
|
||||
if (uids.Count == 0)
|
||||
return [];
|
||||
|
||||
var results = new List<ReceivedEmailContext>(uids.Count);
|
||||
var results = new List<ReceivedEmailDto>(uids.Count);
|
||||
|
||||
foreach (var uid in uids)
|
||||
{
|
||||
@@ -77,11 +77,11 @@ public class LimilabsImapEmailService(
|
||||
var mail = new MailBuilder().CreateFromEml(eml);
|
||||
var flags = await imap.GetFlagsByUIDAsync(uid, cancellationToken);
|
||||
|
||||
var attachments = new List<EmailAttachmentContext>();
|
||||
var attachments = new List<EmailAttachmentDto>();
|
||||
|
||||
foreach (var att in mail.Attachments)
|
||||
{
|
||||
attachments.Add(new EmailAttachmentContext
|
||||
attachments.Add(new EmailAttachmentDto
|
||||
{
|
||||
FileName = att.FileName ?? "attachment",
|
||||
Content = att.Data,
|
||||
@@ -93,7 +93,7 @@ public class LimilabsImapEmailService(
|
||||
|
||||
foreach (var vis in mail.Visuals)
|
||||
{
|
||||
attachments.Add(new EmailAttachmentContext
|
||||
attachments.Add(new EmailAttachmentDto
|
||||
{
|
||||
FileName = vis.FileName ?? "inline",
|
||||
Content = vis.Data,
|
||||
@@ -103,7 +103,7 @@ public class LimilabsImapEmailService(
|
||||
});
|
||||
}
|
||||
|
||||
return new ReceivedEmailContext
|
||||
return new ReceivedEmailDto
|
||||
{
|
||||
Uid = uid,
|
||||
From = mail.From.FirstOrDefault()?.Address ?? string.Empty,
|
||||
|
||||
Reference in New Issue
Block a user