refactor(gmail): route message import through IEmailProvider
ImportSingleMessageAsync now fetches the message + connection through the provider-neutral seam (Email.GetMessageAsync/GetConnectionAsync), mapping the neutral ExternalAttachmentId onto CorrespondenceAttachmentMetadata. The controller's import path no longer touches Gmail directly. OAuth lifecycle, the rich connection-status DTO, and Gmail candidate ranking stay on IGmailOAuthService until a second provider (Microsoft/IMAP) forces the contract shape. 135/135 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -951,9 +951,9 @@ public sealed class GmailController : ControllerBase
|
|||||||
|
|
||||||
private async Task<Correspondence> ImportSingleMessageAsync(string ownerUserId, JobApplication job, string messageId, CancellationToken cancellationToken)
|
private async Task<Correspondence> ImportSingleMessageAsync(string ownerUserId, JobApplication job, string messageId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var detail = await _gmail.GetMessageAsync(ownerUserId, messageId, cancellationToken);
|
var detail = await Email.GetMessageAsync(ownerUserId, messageId, cancellationToken);
|
||||||
var me = await _gmail.GetConnectionAsync(ownerUserId, cancellationToken);
|
var me = await Email.GetConnectionAsync(ownerUserId, cancellationToken);
|
||||||
var gmailAddress = me?.GmailAddress ?? string.Empty;
|
var gmailAddress = me?.Address ?? string.Empty;
|
||||||
var isMe = detail.From.Contains(gmailAddress, StringComparison.OrdinalIgnoreCase);
|
var isMe = detail.From.Contains(gmailAddress, StringComparison.OrdinalIgnoreCase);
|
||||||
var messageDate = detail.Date?.LocalDateTime ?? DateTime.Now;
|
var messageDate = detail.Date?.LocalDateTime ?? DateTime.Now;
|
||||||
|
|
||||||
@@ -974,7 +974,7 @@ public sealed class GmailController : ControllerBase
|
|||||||
FileName = attachment.FileName,
|
FileName = attachment.FileName,
|
||||||
MimeType = attachment.MimeType,
|
MimeType = attachment.MimeType,
|
||||||
SizeBytes = attachment.SizeBytes,
|
SizeBytes = attachment.SizeBytes,
|
||||||
GmailAttachmentId = attachment.GmailAttachmentId,
|
GmailAttachmentId = attachment.ExternalAttachmentId,
|
||||||
Inline = attachment.Inline,
|
Inline = attachment.Inline,
|
||||||
})),
|
})),
|
||||||
Content = string.IsNullOrWhiteSpace(detail.BodyText) ? detail.Snippet : detail.BodyText,
|
Content = string.IsNullOrWhiteSpace(detail.BodyText) ? detail.Snippet : detail.BodyText,
|
||||||
|
|||||||
Reference in New Issue
Block a user