]> git.mxchange.org Git - friendica-addons.git/blobdiff - statusnet/statusnet.php
Merge pull request #223 from annando/1410-application-name
[friendica-addons.git] / statusnet / statusnet.php
index c3591356b6237c035b79edea23bc934b58e8a533..7d0f80c3c5e8d98afa2357af7c089c4997c45b76 100644 (file)
@@ -532,6 +532,9 @@ function statusnet_post_hook(&$a,&$b) {
                return;
 
        // if posts comes from statusnet don't send it back
+       if($b['extid'] == NETWORK_STATUSNET)
+               return;
+
        if($b['app'] == "StatusNet")
                return;
 
@@ -829,7 +832,9 @@ function statusnet_fetchtimeline($a, $uid) {
                        $_REQUEST["type"] = "wall";
                        $_REQUEST["api_source"] = true;
                        $_REQUEST["profile_uid"] = $uid;
-                       $_REQUEST["source"] = "StatusNet";
+                       //$_REQUEST["source"] = "StatusNet";
+                       $_REQUEST["source"] = $post->source;
+                       $_REQUEST["extid"] = NETWORK_STATUSNET;
 
                        //$_REQUEST["date"] = $post->created_at;
 
@@ -872,6 +877,9 @@ function statusnet_address($contact) {
 }
 
 function statusnet_fetch_contact($uid, $contact, $create_user) {
+       if ($contact->statusnet_profile_url == "")
+               return(-1);
+
        // Check if the unique contact is existing
        // To-Do: only update once a while
         $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
@@ -950,16 +958,12 @@ function statusnet_fetch_contact($uid, $contact, $create_user) {
                q("UPDATE `contact` SET `photo` = '%s',
                                        `thumb` = '%s',
                                        `micro` = '%s',
-                                       `name-date` = '%s',
-                                       `uri-date` = '%s',
                                        `avatar-date` = '%s'
                                WHERE `id` = %d",
                        dbesc($photos[0]),
                        dbesc($photos[1]),
                        dbesc($photos[2]),
                        dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
                        intval($contact_id)
                );
 
@@ -971,7 +975,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) {
 
                // check that we have all the photos, this has been known to fail on occasion
 
-               if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
+               if((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
 
                        logger("statusnet_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG);
 
@@ -1338,7 +1342,16 @@ function statusnet_fetchhometimeline($a, $uid) {
        $items = $connection->get('statuses/home_timeline', $parameters);
 
        if (!is_array($items)) {
-               logger("statusnet_fetchhometimeline: Error fetching home timeline: ".print_r($items, true), LOGGER_DEBUG);
+               if (is_object($items) AND isset($items->error))
+                       $errormsg = $items->error;
+               elseif (is_object($items))
+                       $errormsg = print_r($items, true);
+               elseif (is_string($items) OR is_float($items) OR is_int($items))
+                       $errormsg = $items;
+               else
+                       $errormsg = "Unknown error";
+
+               logger("statusnet_fetchhometimeline: Error fetching home timeline: ".$errormsg, LOGGER_DEBUG);
                return;
        }