From 3e816ff745a05de6a996acbe41928a14562b6089 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 17 May 2024 09:45:08 +0200 Subject: [PATCH 01/20] Added body, icon, tag ,renotify to MercureOptions.php for Symfony UX Notify --- .../Bridge/Mercure/MercureOptions.php | 34 ++++++++++++++++++- .../Bridge/Mercure/MercureTransport.php | 4 +++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php index da3b2e8797b34..0d8179cf5e183 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php @@ -23,17 +23,25 @@ final class MercureOptions implements MessageOptionsInterface private ?string $id; private ?string $type; private ?int $retry; + private ?string $body; + private ?string $icon; + private ?string $tag; + private bool $renotify; /** * @param string|string[]|null $topics */ - public function __construct(string|array|null $topics = null, bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null) + public function __construct(string|array|null $topics = null, bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null, ?string $body = null, ?string $icon = null, ?string $tag = null, ?bool $renotify = false) { $this->topics = null !== $topics ? (array) $topics : null; $this->private = $private; $this->id = $id; $this->type = $type; $this->retry = $retry; + $this->body = $body; + $this->icon = $icon; + $this->tag = $tag; + $this->renotify = $renotify; } /** @@ -64,6 +72,26 @@ public function getRetry(): ?int return $this->retry; } + public function getBody(): ?string + { + return $this->body; + } + + public function getIcon(): ?string + { + return $this->icon; + } + + public function getTag(): ?string + { + return $this->tag; + } + + public function isRenotify(): bool + { + return $this->renotify; + } + public function toArray(): array { return [ @@ -72,6 +100,10 @@ public function toArray(): array 'id' => $this->id, 'type' => $this->type, 'retry' => $this->retry, + 'body' => $this->body, + 'icon' => $this->icon, + 'tag' => $this->tag, + 'renotify' => $this->renotify, ]; } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 72559b85fa85f..6c2a6ea636920 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -77,6 +77,10 @@ protected function doSend(MessageInterface $message): SentMessage '@context' => 'https://www.w3.org/ns/activitystreams', 'type' => 'Announce', 'summary' => $message->getSubject(), + 'body' => $options->getBody(), + 'icon' => $options->getIcon(), + 'tag' => $options->getTag(), + 'renotify' => $options->isRenotify(), ]), $options->isPrivate(), $options->getId(), $options->getType(), $options->getRetry()); try { From 6c7428ad41f4a069854f617f2950e43ade06dbfe Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 17 May 2024 10:11:52 +0200 Subject: [PATCH 02/20] Edit CHANGELOG.md --- src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index 1f2b652ac20ea..32691240a1692 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -1,6 +1,8 @@ CHANGELOG ========= + * Added body, icon, tag ,renotify to MercureOptions.php and MercureTransport.php for Symfony UX Notify + 5.3 --- From 7ed8d752fad825ede8c2a058d529483694f910ef Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 17 May 2024 11:53:36 +0200 Subject: [PATCH 03/20] make tests --- .../Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php | 8 ++++++++ .../Bridge/Mercure/Tests/MercureTransportTest.php | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index 7503f9e40456f..77f1355864459 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -24,6 +24,10 @@ public function testConstructWithDefaults() 'id' => null, 'type' => null, 'retry' => null, + 'body' => null, + 'icon' => null, + 'tag' => null, + 'renotify' => false, ]); } @@ -37,6 +41,10 @@ public function testConstructWithParameters() 'id' => 'id', 'type' => 'type', 'retry' => 1, + 'body' => null, + 'icon' => null, + 'tag' => null, + 'renotify' => false, ]); } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php index bfe9190a8e592..77eed3cb2ddd0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php @@ -114,12 +114,13 @@ public function testSendWithMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['/topic/1', '/topic/2'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject"}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); $this->assertTrue($update->isPrivate()); + return 'id'; }); @@ -130,7 +131,7 @@ public function testSendWithMercureOptionsButWithoutOptionTopic() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject"}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); @@ -146,7 +147,7 @@ public function testSendWithoutMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject"}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); $this->assertFalse($update->isPrivate()); return 'id'; From 265f00e184bcc1c265ae3166d63ebaa248cfd30d Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 17 May 2024 12:00:38 +0200 Subject: [PATCH 04/20] make fabbot happy :) --- .../Notifier/Bridge/Mercure/Tests/MercureTransportTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php index 77eed3cb2ddd0..4c81d3635f1b4 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php @@ -120,7 +120,6 @@ public function testSendWithMercureOptions() $this->assertSame(1, $update->getRetry()); $this->assertTrue($update->isPrivate()); - return 'id'; }); From c830aedc16a533229e398b3377067f3c84e7f124 Mon Sep 17 00:00:00 2001 From: ernie76 Date: Tue, 21 May 2024 08:08:22 +0200 Subject: [PATCH 05/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md Co-authored-by: Oskar Stark --- src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index 32691240a1692..e89def5fe267c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= - * Added body, icon, tag ,renotify to MercureOptions.php and MercureTransport.php for Symfony UX Notify + * Add body, icon, tag ,renotify to MercureOptions.php and MercureTransport.php for Symfony UX Notify 5.3 --- From 651a89ff666e6a5e09fb598ba99a44154e5c7c2b Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 22 May 2024 10:22:06 +0200 Subject: [PATCH 06/20] add content to MercureOptions.php for Symfony UX Notify add "mediaType" => "application/json" to MercureOptions.php --- .../Notifier/Bridge/Mercure/CHANGELOG.md | 3 +- .../Bridge/Mercure/MercureOptions.php | 37 ++++--------------- .../Bridge/Mercure/MercureTransport.php | 21 +++++------ .../Mercure/Tests/MercureOptionsTest.php | 12 ++---- .../Mercure/Tests/MercureTransportTest.php | 6 +-- 5 files changed, 25 insertions(+), 54 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index e89def5fe267c..defe108343911 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -1,7 +1,8 @@ CHANGELOG ========= - * Add body, icon, tag ,renotify to MercureOptions.php and MercureTransport.php for Symfony UX Notify + * Add content to MercureOptions.php for Symfony UX Notify + * Add "mediaType" => "application/json" to MercureOptions.php 5.3 --- diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php index 0d8179cf5e183..be7ef199dc3bb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php @@ -23,25 +23,19 @@ final class MercureOptions implements MessageOptionsInterface private ?string $id; private ?string $type; private ?int $retry; - private ?string $body; - private ?string $icon; - private ?string $tag; - private bool $renotify; + private ?array $content; /** * @param string|string[]|null $topics */ - public function __construct(string|array|null $topics = null, bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null, ?string $body = null, ?string $icon = null, ?string $tag = null, ?bool $renotify = false) + public function __construct(string|array|null $topics = null, bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null, ?array $content = null) { $this->topics = null !== $topics ? (array) $topics : null; $this->private = $private; $this->id = $id; $this->type = $type; $this->retry = $retry; - $this->body = $body; - $this->icon = $icon; - $this->tag = $tag; - $this->renotify = $renotify; + $this->content = $content; } /** @@ -72,25 +66,11 @@ public function getRetry(): ?int return $this->retry; } - public function getBody(): ?string + public function getContent(): ?array { - return $this->body; + return $this->content; } - public function getIcon(): ?string - { - return $this->icon; - } - - public function getTag(): ?string - { - return $this->tag; - } - - public function isRenotify(): bool - { - return $this->renotify; - } public function toArray(): array { @@ -100,10 +80,7 @@ public function toArray(): array 'id' => $this->id, 'type' => $this->type, 'retry' => $this->retry, - 'body' => $this->body, - 'icon' => $this->icon, - 'tag' => $this->tag, - 'renotify' => $this->renotify, + 'content' => $this->content, ]; } @@ -111,4 +88,6 @@ public function getRecipientId(): ?string { return null; } + + } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 6c2a6ea636920..26aeb8b7d56ff 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -30,18 +30,17 @@ */ final class MercureTransport extends AbstractTransport { + private HubInterface $hub; + private string $hubId; private string|array $topics; /** * @param string|string[]|null $topics */ - public function __construct( - private HubInterface $hub, - private string $hubId, - string|array|null $topics = null, - ?HttpClientInterface $client = null, - ?EventDispatcherInterface $dispatcher = null, - ) { + public function __construct(HubInterface $hub, string $hubId, string|array|null $topics = null, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) + { + $this->hub = $hub; + $this->hubId = $hubId; $this->topics = $topics ?? 'https://symfony.com/notifier'; parent::__construct($client, $dispatcher); @@ -49,7 +48,7 @@ public function __construct( public function __toString(): string { - return sprintf('mercure://%s%s', $this->hubId, '?'.http_build_query(['topic' => $this->topics], '', '&')); + return sprintf('mercure://%s%s', $this->hubId, null !== $this->topics ? '?'.http_build_query(['topic' => $this->topics], '', '&') : ''); } public function supports(MessageInterface $message): bool @@ -77,10 +76,8 @@ protected function doSend(MessageInterface $message): SentMessage '@context' => 'https://www.w3.org/ns/activitystreams', 'type' => 'Announce', 'summary' => $message->getSubject(), - 'body' => $options->getBody(), - 'icon' => $options->getIcon(), - 'tag' => $options->getTag(), - 'renotify' => $options->isRenotify(), + "mediaType" => "application/json", + 'content' => $options->getContent(), ]), $options->isPrivate(), $options->getId(), $options->getType(), $options->getRetry()); try { diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index 77f1355864459..b25157240d34a 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -24,16 +24,13 @@ public function testConstructWithDefaults() 'id' => null, 'type' => null, 'retry' => null, - 'body' => null, - 'icon' => null, - 'tag' => null, - 'renotify' => false, + 'content' => null ]); } public function testConstructWithParameters() { - $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1)); + $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1, null)); $this->assertSame($options->toArray(), [ 'topics' => ['/topic/1'], @@ -41,10 +38,7 @@ public function testConstructWithParameters() 'id' => 'id', 'type' => 'type', 'retry' => 1, - 'body' => null, - 'icon' => null, - 'tag' => null, - 'renotify' => false, + 'content' => null ]); } diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php index 4c81d3635f1b4..8ef777a5d909f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php @@ -114,7 +114,7 @@ public function testSendWithMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['/topic/1', '/topic/2'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); @@ -130,7 +130,7 @@ public function testSendWithMercureOptionsButWithoutOptionTopic() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); @@ -146,7 +146,7 @@ public function testSendWithoutMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","body":null,"icon":null,"tag":null,"renotify":false}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); $this->assertFalse($update->isPrivate()); return 'id'; From b5eeda69c2774bc5ed71a0bdd4ec575c2a7d64bf Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 22 May 2024 10:34:07 +0200 Subject: [PATCH 07/20] edit unit test for MercureTransportTest.php --- .../Notifier/Bridge/Mercure/Tests/MercureTransportTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php index 8ef777a5d909f..6e7c391b7278d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureTransportTest.php @@ -114,7 +114,7 @@ public function testSendWithMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['/topic/1', '/topic/2'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","mediaType":"application\/json","content":null}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); @@ -130,7 +130,7 @@ public function testSendWithMercureOptionsButWithoutOptionTopic() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","mediaType":"application\/json","content":null}', $update->getData()); $this->assertSame('id', $update->getId()); $this->assertSame('type', $update->getType()); $this->assertSame(1, $update->getRetry()); @@ -146,7 +146,7 @@ public function testSendWithoutMercureOptions() { $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo'), function (Update $update): string { $this->assertSame(['https://symfony.com/notifier'], $update->getTopics()); - $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","content":null}', $update->getData()); + $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject","mediaType":"application\/json","content":null}', $update->getData()); $this->assertFalse($update->isPrivate()); return 'id'; From f5f1526c45480e2c98c429eeeb44bb772a486a54 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 24 May 2024 07:52:39 +0200 Subject: [PATCH 08/20] chenge __tostring in MercureTransportTest.php back --- .../Component/Notifier/Bridge/Mercure/MercureTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 26aeb8b7d56ff..458b97a5c9dad 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -48,7 +48,7 @@ public function __construct(HubInterface $hub, string $hubId, string|array|null public function __toString(): string { - return sprintf('mercure://%s%s', $this->hubId, null !== $this->topics ? '?'.http_build_query(['topic' => $this->topics], '', '&') : ''); + return sprintf('mercure://%s%s', $this->hubId, '?'.http_build_query(['topic' => $this->topics], '', '&')); } public function supports(MessageInterface $message): bool From 52f41ec1195dbae5fd93b7503a65dc95b1c18be3 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 24 May 2024 09:04:07 +0200 Subject: [PATCH 09/20] delete empty lines --- .../Component/Notifier/Bridge/Mercure/MercureOptions.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php index be7ef199dc3bb..04fec55dcae8c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php @@ -88,6 +88,4 @@ public function getRecipientId(): ?string { return null; } - - } From 5fc0ac57719499580e329385b831d59f02aa3689 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 24 May 2024 09:06:17 +0200 Subject: [PATCH 10/20] delete empty lines --- src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php index 04fec55dcae8c..cd55a68efde71 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureOptions.php @@ -71,7 +71,6 @@ public function getContent(): ?array return $this->content; } - public function toArray(): array { return [ From 4a66651d4deb22d31a21c70f26956ed1f0b3856e Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Fri, 24 May 2024 09:25:31 +0200 Subject: [PATCH 11/20] delete private HubInterface $hub; --- .../Component/Notifier/Bridge/Mercure/MercureTransport.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 458b97a5c9dad..11c0ec5b687ed 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -30,7 +30,6 @@ */ final class MercureTransport extends AbstractTransport { - private HubInterface $hub; private string $hubId; private string|array $topics; From 182f5a9bed84bf7e131d6d6f3c1bf7887996ea3b Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 29 May 2024 13:25:13 +0200 Subject: [PATCH 12/20] delete private string $hubId; --- .../Component/Notifier/Bridge/Mercure/MercureTransport.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 11c0ec5b687ed..fce8a2e7f0680 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -30,7 +30,6 @@ */ final class MercureTransport extends AbstractTransport { - private string $hubId; private string|array $topics; /** From 9095164044ddd67c5bacbbe11d57102399d8ab96 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 29 May 2024 13:39:36 +0200 Subject: [PATCH 13/20] make __construct multiline optionstest with options --- .../Notifier/Bridge/Mercure/MercureTransport.php | 9 +++++++-- .../Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index fce8a2e7f0680..04384aca86006 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -35,8 +35,13 @@ final class MercureTransport extends AbstractTransport /** * @param string|string[]|null $topics */ - public function __construct(HubInterface $hub, string $hubId, string|array|null $topics = null, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) - { + public function __construct( + private HubInterface $hub, + private string $hubId, + string|array|null $topics = null, + ?HttpClientInterface $client = null, + ?EventDispatcherInterface $dispatcher = null + ) { $this->hub = $hub; $this->hubId = $hubId; $this->topics = $topics ?? 'https://symfony.com/notifier'; diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index b25157240d34a..22c2d97236fcd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -30,7 +30,7 @@ public function testConstructWithDefaults() public function testConstructWithParameters() { - $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1, null)); + $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1, ['tag' => '1234','body' => 'TEST'])); $this->assertSame($options->toArray(), [ 'topics' => ['/topic/1'], @@ -38,7 +38,7 @@ public function testConstructWithParameters() 'id' => 'id', 'type' => 'type', 'retry' => 1, - 'content' => null + 'content' => ['tag' => '1234','body' => 'TEST'] ]); } From 0c2e231d23831411e730295b27d9ebc4f32aadfe Mon Sep 17 00:00:00 2001 From: ernie76 Date: Wed, 29 May 2024 13:42:44 +0200 Subject: [PATCH 14/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php Co-authored-by: Oskar Stark --- .../Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index 22c2d97236fcd..331e38dd84074 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -30,7 +30,7 @@ public function testConstructWithDefaults() public function testConstructWithParameters() { - $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1, ['tag' => '1234','body' => 'TEST'])); + $options = (new MercureOptions('/topic/1', true, 'id', 'type', 1, ['tag' => '1234', 'body' => 'TEST'])); $this->assertSame($options->toArray(), [ 'topics' => ['/topic/1'], From e0c1a9a60f8b23cdf23bb507997a6579290397a9 Mon Sep 17 00:00:00 2001 From: ernie76 Date: Wed, 29 May 2024 13:43:21 +0200 Subject: [PATCH 15/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php Co-authored-by: Oskar Stark --- .../Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php index 331e38dd84074..d3a7ed8aa6a95 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/Tests/MercureOptionsTest.php @@ -38,7 +38,7 @@ public function testConstructWithParameters() 'id' => 'id', 'type' => 'type', 'retry' => 1, - 'content' => ['tag' => '1234','body' => 'TEST'] + 'content' => ['tag' => '1234', 'body' => 'TEST'], ]); } From 89d13ba596b93a84fe6909d72c3cb538d1222037 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 29 May 2024 13:46:08 +0200 Subject: [PATCH 16/20] update CHANGELOG --- src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index defe108343911..90151d4b31f83 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -1,8 +1,9 @@ CHANGELOG ========= - * Add content to MercureOptions.php for Symfony UX Notify - * Add "mediaType" => "application/json" to MercureOptions.php +7.2 +--- + * Add `content` option 5.3 --- From ac8394632eb539215d786e6e9083aa626b2324fd Mon Sep 17 00:00:00 2001 From: ernie76 Date: Wed, 29 May 2024 13:49:17 +0200 Subject: [PATCH 17/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php Co-authored-by: Oskar Stark --- .../Component/Notifier/Bridge/Mercure/MercureTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index 04384aca86006..d47297e04b5c7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -79,7 +79,7 @@ protected function doSend(MessageInterface $message): SentMessage '@context' => 'https://www.w3.org/ns/activitystreams', 'type' => 'Announce', 'summary' => $message->getSubject(), - "mediaType" => "application/json", + 'mediaType' => 'application/json', 'content' => $options->getContent(), ]), $options->isPrivate(), $options->getId(), $options->getType(), $options->getRetry()); From 30958e80b6e189263764669d424516b06be1cb51 Mon Sep 17 00:00:00 2001 From: ernie76 Date: Wed, 29 May 2024 13:49:37 +0200 Subject: [PATCH 18/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php Co-authored-by: Oskar Stark --- .../Component/Notifier/Bridge/Mercure/MercureTransport.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php index d47297e04b5c7..355af24982fff 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php @@ -40,10 +40,8 @@ public function __construct( private string $hubId, string|array|null $topics = null, ?HttpClientInterface $client = null, - ?EventDispatcherInterface $dispatcher = null + ?EventDispatcherInterface $dispatcher = null, ) { - $this->hub = $hub; - $this->hubId = $hubId; $this->topics = $topics ?? 'https://symfony.com/notifier'; parent::__construct($client, $dispatcher); From c3554d2d25301b27cf948171b0b005042671c7a9 Mon Sep 17 00:00:00 2001 From: Sven Scholz Date: Wed, 26 Jun 2024 08:04:45 +0200 Subject: [PATCH 19/20] update CHANGELOG --- src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index 90151d4b31f83..b8d897fb7487a 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -3,6 +3,7 @@ CHANGELOG 7.2 --- + * Add `content` option 5.3 From d27eaf2ea7c34e81dc835c751af5564bd644b838 Mon Sep 17 00:00:00 2001 From: ernie76 Date: Wed, 2 Apr 2025 08:00:34 +0200 Subject: [PATCH 20/20] Update src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md Co-authored-by: Oskar Stark --- src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md index b8d897fb7487a..29eb84188aded 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mercure/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -7.2 +7.3 --- * Add `content` option