diff options
| author | winter | 2025-01-14 17:04:57 +0000 |
|---|---|---|
| committer | winter | 2025-01-14 17:04:57 +0000 |
| commit | d7940cf9470ee8377cf6484f4a20869c62d48685 (patch) | |
| tree | 7d6848093e1111636b380e894fda89562f9278d8 /Digitigrade/Model | |
| parent | 3ce58a33945fc858ac4f8b2b8471dff0cf294863 (diff) | |
don't retry pushing to an instance with no push endpoint
Diffstat (limited to 'Digitigrade/Model')
| -rw-r--r-- | Digitigrade/Model/Instance.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php index b3a179f..2b07b9a 100644 --- a/Digitigrade/Model/Instance.php +++ b/Digitigrade/Model/Instance.php @@ -1,6 +1,7 @@ <?php namespace Digitigrade\Model; +use Digitigrade\Exception\EndpointMissingException; use Digitigrade\GlobalConfig; use Digitigrade\Job\RefreshOutboundAuthToken; @@ -88,7 +89,7 @@ class Instance extends FetchableModel { public function beginOutboundAuth() { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } file_get_contents($authEndpoint . '?phase=dialback&target=' . urlencode(path_to_uri('/auth/dialback'))); } @@ -96,7 +97,7 @@ class Instance extends FetchableModel { public function requestOutboundAuthToken(string $secret) { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } $response = file_get_contents($authEndpoint . '?phase=token&secret=' . urlencode($secret)); if ($response === false) { @@ -123,7 +124,7 @@ class Instance extends FetchableModel { public function refreshOutboundAuthToken() { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't refresh outbound token for $this->domain because i don't already have one"); @@ -147,7 +148,7 @@ class Instance extends FetchableModel { private function subscribeOrUnsubscribe(bool $isUnsubscribe): bool { if (!isset($this->endpoints->subscribe, $this->endpoints->unsubscribe)) { - throw new \RuntimeException("can't (un)subscribe to $this->domain because it doesn't have the right endpoints"); + throw new EndpointMissingException($this, 'subscribe'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't (un)subscribe to $this->domain because i don't have an outbound token for it"); @@ -189,7 +190,7 @@ class Instance extends FetchableModel { public function pushObject(PushableModel $obj) { if (!isset($this->endpoints->push)) { - throw new \RuntimeException("can't push to $this->domain because it doesn't have a push endpoint"); + throw new EndpointMissingException($this, 'push'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't push to $this->domain because i don't have an outbound token for it"); |
