Skip to content

Commit

Permalink
* add backwards compatibility in the __construct() of relay for the $…
Browse files Browse the repository at this point in the history
…message argument which was used in version < 1.2.4

* fix WebsocketClient response (message) which returned an array instead of a string for the json_decode function
  • Loading branch information
Sebastix committed Jul 4, 2024
1 parent 51c0376 commit 2fe0a63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Application/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public function run($args): void
protected function showHelp($message): void
{
print "\n[error] " . $message . "\n\nUsage:\n";
print "nostr-php --content \"Hello world!\" --key /home/path/to/nostr-private.key --relay wss://nostr.pleb.network\n\n";
print "bin/nostr-php --content \"Hello world!\" --key /home/path/to/nostr-private.key --relay wss://nostr.pleb.network\n\n";
}
}
8 changes: 6 additions & 2 deletions src/Relay/Relay.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ class Relay implements RelayInterface
* @param string $websocket
* The socket URL.
*/
public function __construct(string $websocket)
public function __construct(string $websocket, MessageInterface $message = null)
{
$this->url = $websocket;
// Backwards compatibility for version <1.2.4
if ($message !== null) {
$this->setMessage($message);
}
}

/**
Expand Down Expand Up @@ -87,7 +91,7 @@ public function send(): CommandResultInterface
$client->text($this->payload);
$response = $client->receive();
$client->disconnect();
$response = json_decode($response);
$response = json_decode($response->getContent());
if ($response[0] === 'NOTICE') {
throw new \RuntimeException($response[1]);
}
Expand Down

0 comments on commit 2fe0a63

Please sign in to comment.