feat(email): add safe message detail
CI and Deploy / test (pull_request) Failing after 1m29s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-09 21:44:24 +02:00
parent 6f0e9bb516
commit a20775c24a
6 changed files with 262 additions and 23 deletions
+14 -14
View File
@@ -5,24 +5,24 @@ using Microsoft.AspNetCore.Mvc;
namespace JobTrackerApi.Controllers;
public sealed record EmailMessageDetailDto(
string Id,
string ThreadId,
string Subject,
string From,
string To,
DateTimeOffset? Date,
string Snippet,
string BodyText,
IReadOnlyList<string> Labels,
IReadOnlyList<EmailAttachmentRef> Attachments);
[ApiController]
[Route("api/email")]
[Authorize(AuthenticationSchemes = "local")]
public sealed class EmailController(IEmailProviderRegistry providers) : ControllerBase
{
public sealed record ProviderStatus(string Provider, string DisplayName, bool Connected, string? Address, bool CanRead, bool CanSend);
public sealed record MessageDetail(
string Id,
string ThreadId,
string Subject,
string From,
string To,
DateTimeOffset? Date,
string Snippet,
string BodyText,
IReadOnlyList<string> Labels,
IReadOnlyList<EmailAttachmentRef> Attachments);
[HttpGet("providers")]
public async Task<ActionResult<IReadOnlyList<ProviderStatus>>> GetProviders(CancellationToken cancellationToken)
{
@@ -82,7 +82,7 @@ public sealed class EmailController(IEmailProviderRegistry providers) : Controll
}
[HttpGet("message")]
public async Task<ActionResult<MessageDetail>> GetMessage(
public async Task<ActionResult<EmailMessageDetailDto>> GetMessage(
[FromQuery] string provider,
[FromQuery] string messageId,
CancellationToken cancellationToken)
@@ -97,7 +97,7 @@ public sealed class EmailController(IEmailProviderRegistry providers) : Controll
return Conflict(new ProblemDetails { Title = "Email provider is not connected." });
var detail = await resolved.GetMessageAsync(ownerUserId, messageId.Trim(), cancellationToken);
return Ok(new MessageDetail(
return Ok(new EmailMessageDetailDto(
detail.Id,
detail.ThreadId,
detail.Subject,