From d7940cf9470ee8377cf6484f4a20869c62d48685 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 14 Jan 2025 17:04:57 +0000 Subject: don't retry pushing to an instance with no push endpoint --- Digitigrade/Model/Instance.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Digitigrade/Model') 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 @@ 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"); -- cgit v1.3