fix: attachment upload on send
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -929,6 +929,19 @@ class RemoteMailService {
|
||||
$submission->message('#' . $messageCreateId);
|
||||
|
||||
$bundle = $this->dataStore->perform([$r0, $r1]);
|
||||
$messageResponse = $bundle->response(0);
|
||||
if ($messageResponse instanceof ResponseException) {
|
||||
throw new Exception($messageResponse->type() . ': ' . $messageResponse->description(), 1);
|
||||
}
|
||||
if (method_exists($messageResponse, 'createFailure')) {
|
||||
$failure = $messageResponse->createFailure($messageCreateId);
|
||||
if (is_array($failure)) {
|
||||
$type = $failure['type'] ?? 'unknownError';
|
||||
$description = $failure['description'] ?? 'Email creation failed';
|
||||
throw new Exception($type . ': ' . $description, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$response = $bundle->response(1);
|
||||
if ($response instanceof ResponseException) {
|
||||
if ($response->type() === 'unknownMethod') {
|
||||
@@ -940,6 +953,18 @@ class RemoteMailService {
|
||||
return $this->extractSubmissionIdentifier($response, $submissionCreateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload attachment content and return its JMAP blob identifier.
|
||||
*/
|
||||
public function blobDeposit(string $type, string $data): string {
|
||||
$response = json_decode($this->dataStore->upload($this->dataAccount, $type, $data), true);
|
||||
if (!is_array($response) || !isset($response['blobId']) || !is_string($response['blobId']) || $response['blobId'] === '') {
|
||||
throw new Exception('JMAP attachment upload did not return a blob identifier', 1);
|
||||
}
|
||||
|
||||
return $response['blobId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit an existing draft message.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user