From ef32c865bb1118b85cf9d5e535bbabb66e930ebb Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 18 Dec 2020 09:40:38 +0100 Subject: [PATCH] [Notifier][Zulip] Host is required --- .../Notifier/Bridge/Mattermost/MattermostTransport.php | 5 +++++ src/Symfony/Component/Notifier/Bridge/Zulip/README.md | 3 ++- .../Component/Notifier/Bridge/Zulip/ZulipTransport.php | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php index 903f067f43d7c..e638e8fae71ec 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php @@ -83,4 +83,9 @@ protected function doSend(MessageInterface $message): SentMessage return $sentMessage; } + + protected function getEndpoint(): ?string + { + return $this->host.($this->port ? ':'.$this->port : ''); + } } diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/README.md b/src/Symfony/Component/Notifier/Bridge/Zulip/README.md index a81a4154a56a0..134270064ba8d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/README.md @@ -7,12 +7,13 @@ DSN example ----------- ``` -ZULIP_DSN=zulip://EMAIL:TOKEN@default?channel=CHANNEL +ZULIP_DSN=zulip://EMAIL:TOKEN@URL?channel=CHANNEL ``` where: - `EMAIL` is your Zulip email - `TOKEN` is your Zulip token + - `URL` is your Zulip url - `CHANNEL` is the channel Resources diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php b/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php index 297676202c2ae..9e1315485edc2 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php @@ -63,8 +63,6 @@ protected function doSend(MessageInterface $message): SentMessage throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, ZulipOptions::class)); } - $endpoint = sprintf('https://%s/api/v1/messages', $this->getEndpoint()); - $options = ($opts = $message->getOptions()) ? $opts->toArray() : []; $options['content'] = $message->getSubject(); @@ -80,6 +78,8 @@ protected function doSend(MessageInterface $message): SentMessage $options['to'] = $message->getRecipientId(); } + $endpoint = sprintf('https://%s/api/v1/messages', $this->getEndpoint()); + $response = $this->client->request('POST', $endpoint, [ 'auth_basic' => $this->email.':'.$this->token, 'body' => $options,