fix: move draft to sent and clear draft flag on submission
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user