[ActivityPub][POSTMAN] Do not die on network errors
This commit is contained in:
parent
bdb4c54fa8
commit
31433db539
@ -87,7 +87,7 @@ class Activitypub_postman
|
||||
* @param string $method request method
|
||||
* @return GNUsocial_HTTPResponse
|
||||
* @throws HTTP_Request2_Exception
|
||||
* @throws Exception
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
*/
|
||||
public function send($data, $inbox, $method = 'POST')
|
||||
@ -224,8 +224,8 @@ class Activitypub_postman
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
|
||||
// accumulate errors for later use, if needed
|
||||
if (!($res->getStatus() == 200 || $res->getStatus() == 202 || $res->getStatus() == 409)) {
|
||||
$res_body = json_decode($res->getBody(), true);
|
||||
@ -233,6 +233,9 @@ class Activitypub_postman
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
} catch (Exception $e){
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
@ -260,6 +263,7 @@ class Activitypub_postman
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
|
||||
// accummulate errors for later use, if needed
|
||||
@ -269,6 +273,9 @@ class Activitypub_postman
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
@ -296,6 +303,7 @@ class Activitypub_postman
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
|
||||
// accummulate errors for later use, if needed
|
||||
@ -305,6 +313,9 @@ class Activitypub_postman
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
@ -361,6 +372,7 @@ class Activitypub_postman
|
||||
);
|
||||
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
|
||||
// accummulate errors for later use, if needed
|
||||
@ -370,6 +382,9 @@ class Activitypub_postman
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
@ -392,6 +407,7 @@ class Activitypub_postman
|
||||
$errors = [];
|
||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
if (!($res->getStatus() == 200 || $res->getStatus() == 202 || $res->getStatus() == 409)) {
|
||||
$res_body = json_decode($res->getBody(), true);
|
||||
@ -399,6 +415,9 @@ class Activitypub_postman
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
throw new Exception(json_encode($errors));
|
||||
@ -419,6 +438,7 @@ class Activitypub_postman
|
||||
|
||||
$errors = [];
|
||||
foreach ($this->to_inbox() as $inbox) {
|
||||
try {
|
||||
$res = $this->send($data, $inbox);
|
||||
|
||||
// accumulate errors for later use, if needed
|
||||
@ -427,6 +447,9 @@ class Activitypub_postman
|
||||
$errors[] = isset($res_body['error']) ?
|
||||
$res_body['error'] : "An unknown error occurred.";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$to_failed[$inbox] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
|
Loading…
Reference in New Issue
Block a user