Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06ea390

Browse files
committed
Implement Novu overrides
1 parent2bac801 commit06ea390

File tree

6 files changed

+51
-7
lines changed

6 files changed

+51
-7
lines changed

‎src/Symfony/Component/Notifier/Bridge/Novu/NovuOptions.php‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@
1818
*/
1919
class NovuOptionsimplements MessageOptionsInterface
2020
{
21+
/**
22+
* @param array{
23+
* email: array{
24+
* from: string|null,
25+
* senderName: string|null,
26+
* replyTo: string|null,
27+
* cc: string[]|null,
28+
* bcc: string[]|null
29+
* }|null
30+
* } $overrides
31+
*
32+
* @see https://docs.novu.co/channels/email/#sending-email-overrides
33+
*/
2134
publicfunction__construct(
2235
privatereadonlystring|null$subscriberId =null,
2336
privatereadonlystring|null$firstName =null,
@@ -26,6 +39,7 @@ public function __construct(
2639
privatereadonlystring|null$phone =null,
2740
privatereadonlystring|null$avatar =null,
2841
privatereadonlystring|null$locale =null,
42+
privatereadonlyarray$overrides = [],
2943
privatereadonlyarray$options = [],
3044
) {
3145
}
@@ -34,11 +48,12 @@ public function toArray(): array
3448
{
3549
returnarray_merge($this->options, [
3650
'firstName' =>$this->firstName,
37-
'lastName' =>$this->lastName,
38-
'email' =>$this->email,
39-
'phone' =>$this->phone,
40-
'avatar' =>$this->avatar,
41-
'locale' =>$this->locale,
51+
'lastName' =>$this->lastName,
52+
'email' =>$this->email,
53+
'phone' =>$this->phone,
54+
'avatar' =>$this->avatar,
55+
'locale' =>$this->locale,
56+
'overrides' =>$this->overrides,
4257
]);
4358
}
4459

‎src/Symfony/Component/Notifier/Bridge/Novu/NovuSubscriberRecipient.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@
1818
*/
1919
class NovuSubscriberRecipientimplements RecipientInterface
2020
{
21+
/**
22+
* @param array{
23+
* email: array{
24+
* from: string|null,
25+
* senderName: string|null,
26+
* replyTo: string|null,
27+
* cc: string[],
28+
* bcc: string[]
29+
* }|null
30+
* } $overrides
31+
*
32+
* @see https://docs.novu.co/channels/email/#sending-email-overrides
33+
*/
2134
publicfunction__construct(
2235
privatereadonlystring$subscriberId,
2336
privatereadonlystring|null$firstName =null,
@@ -26,6 +39,7 @@ public function __construct(
2639
privatereadonlystring|null$phone =null,
2740
privatereadonlystring|null$avatar =null,
2841
privatereadonlystring|null$locale =null,
42+
privatereadonlyarray$overrides = [],
2943
) {
3044
}
3145

@@ -63,4 +77,9 @@ public function getLocale(): ?string
6377
{
6478
return$this->locale;
6579
}
80+
81+
publicfunctiongetOverrides():array
82+
{
83+
return$this->overrides;
84+
}
6685
}

‎src/Symfony/Component/Notifier/Bridge/Novu/NovuTransport.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function doSend(MessageInterface $message): SentMessage
6868
'locale' =>$options['locale'],
6969
],
7070
'payload' =>json_decode($message->getContent()),
71+
'overrides' =>$options['overrides'] ?? [],
7172
];
7273

7374
$endpoint =sprintf('https://%s/v1/events/trigger',$this->getEndpoint());

‎src/Symfony/Component/Notifier/Bridge/Novu/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class NovuNotification extends Notification implements PushNotificationInterface
3131
$recipient->getPhone(),
3232
$recipient->getAvatar(),
3333
$recipient->getLocale(),
34+
$recipient->getOverrides(),
3435
[],
3536
),
3637
);
@@ -60,6 +61,12 @@ $this->notifier->send(
6061
null,
6162
null,
6263
null,
64+
[
65+
'email' => [
66+
'from' => 'no-reply@toppy.nl',
67+
'senderName' => 'No-Reply',
68+
],
69+
],
6370
),
6471
);
6572
```

‎src/Symfony/Component/Notifier/Bridge/Novu/Tests/NovuOptionsTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function testToArray()
3030
null,
3131
null,
3232
[],
33+
[],
3334
);
3435

3536
$this->assertSame(
@@ -40,6 +41,7 @@ public function testToArray()
4041
'phone' =>null,
4142
'avatar' =>null,
4243
'locale' =>null,
44+
'overrides' => [],
4345
],
4446
$options->toArray()
4547
);

‎src/Symfony/Component/Notifier/Bridge/Novu/Tests/NovuTransportTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function toStringProvider(): iterable
3737

3838
publicstaticfunctionsupportedMessagesProvider():iterable
3939
{
40-
yield [newPushMessage('test','{}',newNovuOptions(123,null,null,'test@example.com',null,null,null, []))];
40+
yield [newPushMessage('test','{}',newNovuOptions(123,null,null,'test@example.com',null,null,null, [], []))];
4141
}
4242

4343
publicstaticfunctionunsupportedMessagesProvider():iterable
@@ -63,6 +63,6 @@ public function testWithErrorResponseThrows()
6363
$this->expectException(TransportException::class);
6464
$this->expectExceptionMessageMatches('/400: "subscriberId under property to is not configured"/');
6565

66-
$transport->send(newPushMessage('test','{}',newNovuOptions(123,null,null,'test@example.com',null,null,null, [])));
66+
$transport->send(newPushMessage('test','{}',newNovuOptions(123,null,null,'test@example.com',null,null,null, [], [])));
6767
}
6868
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp