Pumpio: Timeout should now work

This commit is contained in:
Michael Vogel 2015-11-03 00:42:04 +01:00
parent a8489627c1
commit f48b4ae535
2 changed files with 41 additions and 8 deletions

View file

@ -998,6 +998,8 @@ class oauth_client_class
$this->response_status = 0;
$http = new http_class;
$http->debug = ($this->debug && $this->debug_http);
$http->timeout = 30;
$http->data_timeout = 60;
$http->log_debug = true;
$http->sasl_authenticate = 0;
$http->user_agent = $this->oauth_user_agent;

View file

@ -499,7 +499,10 @@ function pumpio_send(&$a,&$b) {
$username = $user.'@'.$host;
$url = 'https://'.$host.'/api/user/'.$user.'/feed';
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
else
$success = false;
if($success) {
@ -585,7 +588,10 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "") {
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed';
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
else
$success = false;
if($success)
logger('pumpio_action '.$username.' '.$action.': success '.$uri);
@ -713,7 +719,10 @@ function pumpio_fetchtimeline(&$a, $uid) {
$username = $user.'@'.$host;
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
else
$success = false;
if (!$success) {
logger('pumpio: error fetching posts for user '.$uid." ".$username." ".print_r($user, true));
@ -1371,7 +1380,10 @@ function pumpio_fetchinbox(&$a, $uid) {
if ($last_id != "")
$url .= '?since='.urlencode($last_id);
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
else
$success = false;
if ($user->items) {
$posts = array_reverse($user->items);
@ -1409,12 +1421,18 @@ function pumpio_getallusers(&$a, $uid) {
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
else
$success = false;
if ($users->totalItems > count($users->items)) {
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
else
$success = false;
}
foreach ($users->items AS $user)
@ -1475,7 +1493,10 @@ function pumpio_queue_hook(&$a,&$b) {
$client->client_id = $consumer_key;
$client->client_secret = $consumer_secret;
if (pumpio_reachable($z['url']))
$success = $client->CallAPI($z['url'], 'POST', $z['post'], array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
else
$success = false;
if($success) {
$post_id = $user->object->id;
@ -1623,7 +1644,10 @@ function pumpio_fetchallcomments(&$a, $uid, $id) {
logger("pumpio_fetchallcomments: fetching comment for user ".$uid." url ".$url);
if (pumpio_reachable($url))
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $item);
else
$success = false;
if (!$success)
return;
@ -1688,6 +1712,13 @@ function pumpio_fetchallcomments(&$a, $uid, $id) {
}
}
function pumpio_reachable($url) {
$data = z_fetch_url($url, false, $redirects, array('timeout'=>10));
return($data['success']);
}
/*
To-Do:
- edit own notes