Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Auth headers created by http client
  • Loading branch information
jirikmik authored Aug 26, 2024
commit b6e97321897881aff50b0aafbfa85cda871eb85d
23 changes: 10 additions & 13 deletions src/Symfony/Component/Notifier/Bridge/Ntfy/NtfyTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,26 @@ protected function doSend(MessageInterface $message): SentMessage
$opts = NtfyOptions::fromNotification($notification);
}

$options = $opts ? $opts->toArray() : [];
$json_options = $opts? $opts->toArray() : [];
Copy link
Member

@fabpot fabpot Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$json_options = $opts? $opts->toArray() : [];
$jsonOptions = $opts ? $opts->toArray() : [];


$options['topic'] = $this->getTopic();
$json_options['topic'] = $this->getTopic();

if (!isset($options['title'])) {
$options['title'] = $message->getSubject();
if (!isset($json_options['title'])) {
$json_options['title'] = $message->getSubject();
}
if (!isset($options['message'])) {
$options['message'] = $message->getContent();
if (!isset($json_options['message'])) {
$json_options['message'] = $message->getContent();
}

$headers = [];
$client_options = ['json' => $json_options];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$client_options = ['json' => $json_options];
$clientOptions = ['json' => $json_options];


if (null !== $this->user && null !== $this->password) {
$headers['Authorization'] = 'Basic '.base64_encode($this->user.':'.$this->password);
$client_options['auth_basic'] = [$this->user, $this->password];
} elseif (null !== $this->password) {
$headers['Authorization'] = 'Bearer '.$this->password;
$client_options['auth_bearer'] = $this->password;
}

$response = $this->client->request('POST', ($this->secureHttp ? 'https' : 'http').'://'.$this->getEndpoint(), [
'headers' => $headers,
'json' => $options,
]);
$response = $this->client->request('POST', ($this->secureHttp? 'https' : 'http') . '://' . $this->getEndpoint(), $client_options);

try {
$statusCode = $response->getStatusCode();
Expand Down
Loading