aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model
diff options
context:
space:
mode:
authorwinter2025-04-03 22:06:47 +0100
committerwinter2025-04-03 22:06:47 +0100
commit44212e6248c93171ddedb51bfdb212ce8ffed695 (patch)
tree26d87e7ddbc887d5c727d1b45f09807226e71976 /Digitigrade/Model
parentdc1deda3a02e3ebc31d4ed3a256580469cf83c0e (diff)
indicate error on failed push (status != 20x)
Diffstat (limited to 'Digitigrade/Model')
-rw-r--r--Digitigrade/Model/Instance.php11
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