[Notifier] [Infobip][Zulip] Host is required

This commit is contained in:
Oskar Stark 2020-12-18 09:51:04 +01:00 committed by Nicolas Grekas
parent 9e87661911
commit cfd932e036
5 changed files with 18 additions and 7 deletions

View File

@ -86,4 +86,9 @@ final class InfobipTransport extends AbstractTransport
return new SentMessage($message, (string) $this); return new SentMessage($message, (string) $this);
} }
protected function getEndpoint(): ?string
{
return $this->host.($this->port ? ':'.$this->port : '');
}
} }

View File

@ -1,18 +1,18 @@
Infobip Notifier Infobip Notifier
================ ================
Provides Infobip integration for Symfony Notifier. Provides [Infobip](https://infobip.com) integration for Symfony Notifier.
DSN example DSN example
----------- -----------
``` ```
INFOBIP_DSN=infobip://AUTH_TOKEN@INFOBIP_HOST?from=FROM INFOBIP_DSN=infobip://AUTH_TOKEN@HOST?from=FROM
``` ```
where: where:
- `AUTH_TOKEN` is your Infobip auth token - `AUTH_TOKEN` is your Infobip auth token
- `INFOBIP_HOST` is your Infobip host - `HOST` is your Infobip host
- `FROM` is the sender - `FROM` is the sender
Resources Resources

View File

@ -78,9 +78,14 @@ final class MattermostTransport extends AbstractTransport
$success = $response->toArray(false); $success = $response->toArray(false);
$sentMessage = new SentMessage($sentMessage, (string) $this); $sentMessage = new SentMessage($message, (string) $this);
$sentMessage->setMessageId($success['id']); $sentMessage->setMessageId($success['id']);
return $sentMessage; return $sentMessage;
} }
protected function getEndpoint(): ?string
{
return $this->host.($this->port ? ':'.$this->port : '');
}
} }

View File

@ -7,12 +7,13 @@ DSN example
----------- -----------
``` ```
ZULIP_DSN=zulip://EMAIL:TOKEN@default?channel=CHANNEL ZULIP_DSN=zulip://EMAIL:TOKEN@HOST?channel=CHANNEL
``` ```
where: where:
- `EMAIL` is your Zulip email - `EMAIL` is your Zulip email
- `TOKEN` is your Zulip token - `TOKEN` is your Zulip token
- `HOST` is your Zulip host
- `CHANNEL` is the channel - `CHANNEL` is the channel
Resources Resources

View File

@ -63,8 +63,6 @@ class ZulipTransport extends AbstractTransport
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, ZulipOptions::class)); 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 = ($opts = $message->getOptions()) ? $opts->toArray() : [];
$options['content'] = $message->getSubject(); $options['content'] = $message->getSubject();
@ -80,6 +78,8 @@ class ZulipTransport extends AbstractTransport
$options['to'] = $message->getRecipientId(); $options['to'] = $message->getRecipientId();
} }
$endpoint = sprintf('https://%s/api/v1/messages', $this->getEndpoint());
$response = $this->client->request('POST', $endpoint, [ $response = $this->client->request('POST', $endpoint, [
'auth_basic' => $this->email.':'.$this->token, 'auth_basic' => $this->email.':'.$this->token,
'body' => $options, 'body' => $options,