diff options
Diffstat (limited to 'Digitigrade/Model')
| -rw-r--r-- | Digitigrade/Model/Instance.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php index 2bcc258..35a0978 100644 --- a/Digitigrade/Model/Instance.php +++ b/Digitigrade/Model/Instance.php @@ -199,7 +199,14 @@ class Instance extends FetchableModel { return false; } - public function pushObject(PushableModel $obj) { + /** + * Pushes the given object to this instance + * @param PushableModel $obj + * @throws EndpointMissingException if this instance has no push endpoint + * @throws AuthException if we aren't authenticated with the remote instance + * @return bool success or failure + */ + public function pushObject(PushableModel $obj): bool { if (!isset($this->endpoints->push)) { throw new EndpointMissingException($this, 'push'); } @@ -216,7 +223,7 @@ class Instance extends FetchableModel { 'content' => json_encode($obj) ]]); file_get_contents($this->endpoints->push, context: $context); - if (str_contains($http_response_header[0], '200')) { + if (str_contains($http_response_header[0], ' 20')) { return true; } elseif (str_contains($http_response_header[0], '401') || str_contains($http_response_header[0], '403')) { // in this case we can't be certain whether it failed because wrong token or because they're not subscribed to us |
