]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/omb.php
Updated Cloudy theme default avatars and minor CSS
[quix0rs-gnu-social.git] / lib / omb.php
index f2dbef5ba945f97ed10c172cd5e3a5367c844035..e8e1acc4139b6aa59fe916f1938e6817986ffa19 100644 (file)
@@ -206,7 +206,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));
+                             array('User-AgentLaconica/' . LACONICA_VERSION));
 
     common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
 
@@ -239,7 +239,7 @@ function omb_broadcast_profile($profile)
         while ($sub->fetch()) {
             $rp = Remote_profile::staticGet('id', $sub->subscriber);
             if ($rp) {
-                if (!$updated[$rp->updateprofileurl]) {
+                if (!array_key_exists($rp->updateprofileurl, $updated)) {
                     if (omb_update_profile($profile, $rp, $sub)) {
                         $updated[$rp->updateprofileurl] = true;
                     }
@@ -251,7 +251,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);
@@ -291,11 +290,13 @@ function omb_update_profile($profile, $remote_profile, $subscription)
     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-AgentLaconica/' . LACONICA_VERSION));
 
     common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
 
-    if ($result->status == 403) { # not authorized, don't send again
+    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__);
         $subscription->delete();
         return false;
@@ -304,7 +305,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;