Improving thread mapping for all synchronizers.
This commit is contained in:
@@ -1183,6 +1183,9 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
message.ThreadId = singleDraftRequest.Item.ThreadId;
|
||||
}
|
||||
|
||||
// Local draft mapping header must never leak to recipients.
|
||||
singleDraftRequest.Request.Mime.Headers.Remove(Domain.Constants.WinoLocalDraftHeader);
|
||||
|
||||
singleDraftRequest.Request.Mime.Prepare(EncodingConstraint.None);
|
||||
|
||||
var mimeString = singleDraftRequest.Request.Mime.ToString();
|
||||
|
||||
@@ -1812,6 +1812,10 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
{
|
||||
await HandleFailedResponseAsync(bundle, response, errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
await HandleSuccessfulResponseAsync(bundle, response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1859,6 +1863,39 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleSuccessfulResponseAsync(IRequestBundle<RequestInformation> bundle, HttpResponseMessage response)
|
||||
{
|
||||
if (bundle?.UIChangeRequest is not CreateDraftRequest createDraftRequest)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(content))
|
||||
return;
|
||||
|
||||
var json = JsonNode.Parse(content);
|
||||
var createdDraftId = json?["id"]?.GetValue<string>();
|
||||
if (string.IsNullOrWhiteSpace(createdDraftId))
|
||||
return;
|
||||
|
||||
var createdConversationId = json?["conversationId"]?.GetValue<string>();
|
||||
var localDraft = createDraftRequest.DraftPreperationRequest.CreatedLocalDraftCopy;
|
||||
|
||||
await _outlookChangeProcessor.MapLocalDraftAsync(
|
||||
Account.Id,
|
||||
localDraft.UniqueId,
|
||||
createdDraftId,
|
||||
createdConversationId,
|
||||
createdConversationId).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Draft mapping is best-effort here. Delta sync mapping remains as fallback.
|
||||
_logger.Debug(ex, "Failed to map Outlook draft from create-draft response.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowBatchExecutionException(List<string> errors)
|
||||
{
|
||||
var formattedErrorString = string.Join("\n",
|
||||
|
||||
Reference in New Issue
Block a user