mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
increase timeout on calls to api.lbry.com
This commit is contained in:
parent
1f277c22e2
commit
970ec88e26
1 changed files with 15 additions and 18 deletions
33
lib/thirdparty/LBRY.class.php
vendored
33
lib/thirdparty/LBRY.class.php
vendored
|
@ -3,6 +3,8 @@
|
|||
|
||||
class LBRY
|
||||
{
|
||||
const DEFAULT_TIMEOUT = 10;
|
||||
|
||||
public static function getApiUrl($endpoint)
|
||||
{
|
||||
if (!strlen(Config::get(Config::LBRY_API_SERVER)) > 0) {
|
||||
|
@ -26,34 +28,29 @@ class LBRY
|
|||
return Curl::post(static::getApiUrl('/list/subscribe'), array_filter([
|
||||
'email' => $email,
|
||||
'tag' => $tag,
|
||||
]), ['json_response' => true]);
|
||||
}
|
||||
|
||||
public static function editEmailSettings($token, $email, $isPrimary =null, $isEnabled = null)
|
||||
{
|
||||
return Curl::post(static::getApiUrl('/user_email/edit'), ['auth_token' => $token], ['email' => $email], ['is_primary' => $isPrimary], ['is_enabled' => $isEnabled]);
|
||||
]), ['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
|
||||
public static function emailStatus($token)
|
||||
{
|
||||
list($status, $headers, $body) = Curl::doCurl(Curl::POST, static::getApiUrl('/user_email/status'), ['auth_token' => $token], ['json_response' => true]);
|
||||
list($status, $headers, $body) = Curl::doCurl(
|
||||
Curl::POST,
|
||||
static::getApiUrl('/user_email/status'),
|
||||
['auth_token' => $token],
|
||||
['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]
|
||||
);
|
||||
return array($status,$headers,$body);
|
||||
}
|
||||
|
||||
public static function applyTags($type, $token, $tags)
|
||||
{
|
||||
return Curl::post(static::getApiUrl('/user_tag/edit'), ['auth_token' => $token], [$type => $tags]);
|
||||
}
|
||||
|
||||
public static function unsubscribe($email)
|
||||
{
|
||||
return Curl::post(static::getApiUrl('/user/unsubscribe'), ['email' => $email], ['json_response' => true]);
|
||||
return Curl::post(static::getApiUrl('/user/unsubscribe'), ['email' => $email], ['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
|
||||
public static function connectYoutube($channel_name, $immediateSync = false)
|
||||
{
|
||||
// Uncomment next line for production and comment other return
|
||||
return Curl::post(static::getApiUrl('/yt/new'), [ 'desired_lbry_channel_name' => $channel_name, 'immediate_sync' => $immediateSync, 'type' => 'sync' ], [ 'json_response' => true ]);
|
||||
return Curl::post(static::getApiUrl('/yt/new'), [ 'desired_lbry_channel_name' => $channel_name, 'immediate_sync' => $immediateSync, 'type' => 'sync' ], [ 'json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT ]);
|
||||
|
||||
// Uncomment next line for development and comment other return (this also requires the testnet API)
|
||||
// return Curl::post(static::getApiUrl('/yt/new'), [
|
||||
|
@ -69,12 +66,12 @@ class LBRY
|
|||
// Check the sync status
|
||||
public static function statusYoutube($status_token)
|
||||
{
|
||||
return Curl::get(static::getApiUrl('/yt/status'), ['status_token' => $status_token], ['json_response' => true]);
|
||||
return Curl::get(static::getApiUrl('/yt/status'), ['status_token' => $status_token], ['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
|
||||
public static function youtubeReward()
|
||||
{
|
||||
return CurlWithCache::post(static::getApiUrl('/yt/rewards'), [], ['cache' => 3600, 'json_response' => true]);
|
||||
return CurlWithCache::post(static::getApiUrl('/yt/rewards'), [], ['cache' => 3600, 'json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
|
||||
public static function editYouTube($status_token, $channel_name, $email, $sync_consent)
|
||||
|
@ -97,13 +94,13 @@ class LBRY
|
|||
$postParams['new_preferred_channel'] = $channel_name;
|
||||
}
|
||||
|
||||
return Curl::post(static::getApiUrl("/yt/update"), $postParams, ['json_response' => true]);
|
||||
return Curl::post(static::getApiUrl("/yt/update"), $postParams, ['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
|
||||
public static function logWebVisitor($site, $visitorID, $IPAddress)
|
||||
{
|
||||
if (IS_PRODUCTION) {
|
||||
return Curl::post(static::getApiUrl("/visitor/new"), ['site' => $site, 'visitor_id' => $visitorID, 'ip_address' => $IPAddress], ['json_response' => true]);
|
||||
return Curl::post(static::getApiUrl("/visitor/new"), ['site' => $site, 'visitor_id' => $visitorID, 'ip_address' => $IPAddress], ['json_response' => true, 'timeout' => static::DEFAULT_TIMEOUT]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue