X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fomb.php;h=7dca760c6951da3c72e2e71132d7c6c133d12400;hb=c0eca0e59b1b9bb74d4457348d1e310e18cc082f;hp=29e14c75f76adff6255e62010b3e5e46b999b0d8;hpb=34a61b40f47a52d1fdcf7cd907f3ac53b96b038e;p=quix0rs-gnu-social.git diff --git a/lib/omb.php b/lib/omb.php index 29e14c75f7..7dca760c69 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -1,7 +1,7 @@ . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once('OAuth.php'); require_once(INSTALLDIR.'/lib/oauthstore.php'); @@ -66,7 +66,7 @@ function omb_oauth_datastore() { static $store = null; if (!$store) { - $store = new LaconicaOAuthDataStore(); + $store = new StatusNetOAuthDataStore(); } return $store; } @@ -135,7 +135,7 @@ function omb_broadcast_remote_subscribers($notice) $posted = array(); while ($rp->fetch()) { - if (!$posted[$rp->postnoticeurl]) { + if (!array_key_exists($rp->postnoticeurl, $posted)) { common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl); if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) { common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl); @@ -159,13 +159,9 @@ function omb_post_notice($notice, $remote_profile, $subscription) function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) { - - common_debug('Posting notice ' . $notice->id . ' to ' . $postnoticeurl, __FILE__); - $user = User::staticGet('id', $notice->profile_id); if (!$user) { - common_debug('Failed to get user for notice ' . $notice->id . ', profile = ' . $notice->profile_id, __FILE__); return false; } @@ -206,9 +202,7 @@ function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); - - common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); + array('User-Agent: StatusNet/' . STATUSNET_VERSION)); if ($result->status == 403) { # not authorized, don't send again common_debug('403 result, deleting subscription', __FILE__); @@ -251,7 +245,6 @@ function omb_broadcast_profile($profile) function omb_update_profile($profile, $remote_profile, $subscription) { - global $config; # for license URL $user = User::staticGet($profile->id); $con = omb_oauth_consumer(); $token = new OAuthToken($subscription->token, $subscription->secret); @@ -287,15 +280,11 @@ function omb_update_profile($profile, $remote_profile, $subscription) $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); - common_debug('request URL = '.$req->get_normalized_http_url(), __FILE__); - common_debug('postdata = '.$req->to_postdata(), __FILE__); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: StatusNet/' . STATUSNET_VERSION)); - common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); - - if (empty($result) || $result) { + if (empty($result) || !$result) { common_debug("Unable to contact " . $req->get_normalized_http_url()); } else if ($result->status == 403) { # not authorized, don't send again common_debug('403 result, deleting subscription', __FILE__); @@ -306,7 +295,7 @@ function omb_update_profile($profile, $remote_profile, $subscription) return false; } else { # success! parse_str($result->body, $return); - if ($return['omb_version'] == OMB_VERSION_01) { + if (isset($return['omb_version']) && $return['omb_version'] === OMB_VERSION_01) { return true; } else { return false;