fix: composition send responses and notifications

Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
2026-06-16 23:41:02 -04:00
parent 27cba6ecff
commit 0af38cf50c
8 changed files with 225 additions and 136 deletions
+25 -6
View File
@@ -10,6 +10,7 @@ use KTXF\Mail\Object\AddressInterface;
use KTXF\Mail\Object\MessagePart;
use KTXF\Mail\Object\MessagePropertiesMutableInterface;
use KTXF\Mail\Service\ServiceEntitySubmitInterface;
use KTXF\Mail\Submission\EntitySubmitResult;
use KTXF\Resource\Identifier\EntityIdentifierInterface;
use KTXF\Resource\Identifier\ResourceIdentifier;
use KTXF\Utile\UUID;
@@ -158,7 +159,7 @@ class CompositionManager {
if ($sender['address'] === '' || !filter_var($sender['address'], FILTER_VALIDATE_EMAIL)) {
$result['disposition'] = 'error';
$result['error'] = [
'type' => 'invalid_sender',
'type' => 'composition_invalid_sender',
'message' => 'Invalid sender address',
];
return $result;
@@ -171,15 +172,19 @@ class CompositionManager {
if ($service === null || $service->getEnabled() === false) {
return [
'disposition' => 'error',
'errorCode' => 'service_not_found',
'errorMessage' => "Service not found for sender '$senderAddress' or service is disabled",
'error' => [
'type' => 'service_not_found',
'message' => "Service not found for sender '$senderAddress' or service is disabled",
],
];
}
if ($service instanceof ServiceEntitySubmitInterface === false) {
return [
'disposition' => 'error',
'errorCode' => 'service_not_supported',
'errorMessage' => "Service '{$service->identifier()}' does not support entity submission",
'error' => [
'type' => 'service_not_supported',
'message' => "Service '{$service->identifier()}' does not support entity submission",
],
];
}
@@ -197,7 +202,21 @@ class CompositionManager {
$sendResult = $service->entitySubmit($senderObject, $source, $properties);
return $sendResult->jsonSerialize();
if ($sendResult->disposition === EntitySubmitResult::DISPOSITION_ERROR) {
return [
'identifier' => $identifier,
'disposition' => 'error',
'error' => [
'type' => 'service_submission_error',
'message' => $sendResult->errorMessage ?? 'An unknown error occurred during submission',
],
];
}
return [
'identifier' => $identifier,
'disposition' => 'sent'
];
}
private function buildMessageProperties(