fix: move draft to sent and clear draft flag on submission

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-25 22:42:16 -04:00
parent 72d72b29c5
commit 320db9f82b
2 changed files with 29 additions and 2 deletions
+19
View File
@@ -950,6 +950,23 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
);
}
// determine the sent folder
// if no explicit sent folder is configured, we will attempt to find a folder with the "sent" role.
$postSentTarget = $this->auxiliary['sentTarget'] ?? null;
$postSentTarget = $postSentTarget !== null && (string) $postSentTarget !== ''
? new CollectionIdentifier($this->provider(), (string) $this->identifier(), (string) $postSentTarget)
: $this->resolveCollectionByRole(CollectionRoles::Sent->value);
if ($postSentTarget === null
|| $postSentTarget->provider() !== $this->provider()
|| $postSentTarget->service() !== (string)$this->identifier()) {
return new EntitySubmitResult(
EntitySubmitResult::DISPOSITION_ERROR,
errorCode: 'sent_collection_not_found',
errorMessage: 'No Sent target collection is configured or could be resolved for this service',
);
}
if ($message !== null) {
[$nativeMessage, $nativeAttachments] = $this->messagePayload($message);
} else {
@@ -960,6 +977,8 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
$transportId = $this->mailService->entitySubmitDraft(
$identityId,
(string)$source->entity(),
(string)$source->collection(),
$postSentTarget->collection(),
$nativeMessage,
$nativeAttachments,
);