Skip to content

Commit 0a43e75

Browse files
fixup! feat: use task processing to send emails
Signed-off-by: SebastianKrupinski <[email protected]>
1 parent ee3e7b3 commit 0a43e75

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

lib/public/Json/JsonDeserializable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
*/
1717
interface JsonDeserializable {
1818

19-
public function jsonDeserialize(array|string $data): static;
19+
public static function jsonDeserialize(array|string $data): static;
2020

2121
}

lib/public/Mail/Provider/Address.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ public function jsonSerialize(): array {
5656
*
5757
* @param array array representation of this object
5858
*/
59-
public function jsonDeserialize(array|string $data): static {
59+
public static function jsonDeserialize(array|string $data): static {
6060
if (is_string($data)) {
6161
$data = json_decode($data, true);
6262
}
63-
$this->address = $data['address'] ?? null;
64-
$this->label = $data['label'] ?? null;
63+
$address = $data['address'] ?? null;
64+
$label = $data['label'] ?? null;
6565

66-
return $this;
66+
return new static($address, $label);
6767
}
6868

6969
/**

lib/public/Mail/Provider/Attachment.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ public function jsonSerialize(): array {
6262
*
6363
* @param array array representation of this object
6464
*/
65-
public function jsonDeserialize(array|string $data): static {
65+
public static function jsonDeserialize(array|string $data): static {
6666
if (is_string($data)) {
6767
$data = json_decode($data, true);
6868
}
69-
$this->contents = base64_decode($data['contents'] ?? '');
70-
$this->name = $data['name'] ?? null;
71-
$this->type = $data['type'] ?? null;
72-
$this->embedded = $data['embedded'] ?? false;
69+
$contents = base64_decode($data['contents'] ?? '');
70+
$name = $data['name'] ?? null;
71+
$type = $data['type'] ?? null;
72+
$embedded = $data['embedded'] ?? false;
7373

74-
return $this;
74+
return new static($contents, $name, $type, $embedded);
7575
}
7676

7777
/**

lib/public/Mail/Provider/Message.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,43 +55,37 @@ public function jsonSerialize(): array {
5555
*
5656
* @param array array representation of this object
5757
*/
58-
public function jsonDeserialize(array|string $data): static {
58+
public static function jsonDeserialize(array|string $data): static {
5959
if (is_string($data)) {
60-
$this->data = json_decode($data, true);
61-
} else {
62-
$this->data = $data;
60+
$data = json_decode($data, true);
6361
}
6462
// decode encoded fields
65-
$this->data['bodyHtml'] = base64_decode($data['bodyHtml'] ?? '');
66-
$this->data['bodyPlain'] = base64_decode($data['bodyPlain'] ?? '');
67-
$this->data['subject'] = base64_decode($data['subject'] ?? '');
63+
$data['bodyHtml'] = base64_decode($data['bodyHtml'] ?? '');
64+
$data['bodyPlain'] = base64_decode($data['bodyPlain'] ?? '');
65+
$data['subject'] = base64_decode($data['subject'] ?? '');
6866
// convert object fields
6967
foreach (['from', 'replyTo'] as $field) {
7068
if (isset($data[$field]) && is_array($data[$field])) {
71-
$address = (new Address())->jsonDeserialize($data[$field]);
72-
$this->data[$field] = $address;
69+
$data[$field] = Address::jsonDeserialize($data[$field]);
7370
} else {
74-
$this->data[$field] = null;
71+
$data[$field] = null;
7572
}
7673
}
7774
foreach (['to', 'cc', 'bcc', 'attachments'] as $field) {
78-
$this->data[$field] = [];
7975
if (isset($data[$field]) && is_array($data[$field])) {
80-
foreach ($data[$field] as $item) {
76+
foreach ($data[$field] as $key => $item) {
8177
if (is_array($item)) {
8278
if ($field === 'attachments') {
83-
$attachment = (new Attachment(null, null, null))->jsonDeserialize($item);
84-
$this->data[$field][] = $attachment;
79+
$data[$field][$key] = Attachment::jsonDeserialize($item);
8580
} else {
86-
$address = (new Address())->jsonDeserialize($item);
87-
$this->data[$field][] = $address;
81+
$data[$field][$key] = Address::jsonDeserialize($item);
8882
}
8983
}
9084
}
9185
}
9286
}
9387

94-
return $this;
88+
return new static($data);
9589
}
9690

9791
/**

0 commit comments

Comments
 (0)