]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/omb.php
Update copyright dates in files modified in 2009
[quix0rs-gnu-social.git] / lib / omb.php
index f2dbef5ba945f97ed10c172cd5e3a5367c844035..4f6a9609541ded863edcc62edef1ffcff10f4283 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -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: Laconica/' . LACONICA_VERSION));
 
     if ($result->status == 403) { # not authorized, don't send again
         common_debug('403 result, deleting subscription', __FILE__);
@@ -239,7 +233,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 +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,13 @@ 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-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 +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;