8000 Implement Novu overrides · symfony/symfony@a3a5e80 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3a5e80

Browse files
committed
Implement Novu overrides
1 parent 2bac801 commit a3a5e80

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(
2626
private readonly string|null $phone = null,
2727
private readonly string|null $avatar = null,
2828
private readonly string|null $locale = null,
29+
private readonly array $overrides = [],
2930
private readonly array $options = [],
3031
) {
3132
}
@@ -39,6 +40,7 @@ public function toArray(): array
3940
'phone' => $this->phone,
4041
'avatar' => $this->avatar,
4142
'locale' => $this->locale,
43+
'overrides' => $this->overrides,
4244
]);
4345
}
4446

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

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(
2626
private readonly string|null $phone = null,
2727
private readonly string|null $avatar = null,
2828
private readonly string|null $locale = null,
29+
private readonly array $overrides = [],
2930
) {
3031
}
3132

@@ -63,4 +64,9 @@ public function getLocale(): ?string
6364
{
6465
return $this->locale;
6566
}
67+
68+
public function getOverrides(): array
69+
{
70+
return $this->overrides;
71+
}
6672
}

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

+1
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

+7
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

+2
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

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

3838
public static function supportedMessagesProvider(): iterable
3939
{
40-
yield [new PushMessage('test', '{}', new NovuOptions(123, null, null, 'test@example.com', null, null, null, []))];
40+
yield [new PushMessage('test', '{}', new NovuOptions(123, null, null, 'test@example.com', null, null, null, [], []))];
4141
}
4242

4343
public static function unsupportedMessagesProvider(): 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(new PushMessage('test', '{}', new NovuOptions(123, null, null, 'test@example.com', null, null, null, [])));
66+
$transport->send(new PushMessage('test', '{}', new NovuOptions(123, null, null, 'test@example.com', null, null, null, [], [])));
6767
}
6868
}

0 commit comments

Comments
 (0)
0