]> git.mxchange.org Git - friendica.git/blobdiff - include/ostatus_conversation.php
Auto update of network page only at top of the page
[friendica.git] / include / ostatus_conversation.php
index 480506a06d20bbbc4718badf7003118d249958b6..2fa7d7a54451621b53973a3af59cffdbdaf9d9f2 100644 (file)
@@ -28,7 +28,7 @@ function check_conversations() {
         logger('complete_conversation: cron_start');
 
         $start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
-        $conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'", 
+        $conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'",
                                 dbesc($start));
         foreach ($conversations AS $conversation) {
                 $id = $conversation['oid'];
@@ -44,6 +44,14 @@ function check_conversations() {
 function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) {
        global $a;
 
+       if (intval(get_config('system','ostatus_poll_interval')) == -2)
+               return;
+
+       if ($a->last_ostatus_conversation_url == $conversation_url)
+               return;
+
+       $a->last_ostatus_conversation_url = $conversation_url;
+
        //logger('complete_conversation: completing conversation url '.$conversation_url.' for id '.$itemid);
 
        $messages = q("SELECT `uid`, `parent`, `created` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
@@ -81,7 +89,9 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
        logger('complete_conversation: fetching conversation url '.$conv.' for '.$itemid);
 
        do {
-               $conv_as = file_get_contents($conv."?page=".$pageno);
+               $conv_as = fetch_url($conv."?page=".$pageno);
+               //$conv_as = fetch_url($conv."?page=".$pageno, false, 0, 10);
+               //$conv_as = file_get_contents($conv."?page=".$pageno);
                $conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
                $conv_as = json_decode($conv_as);
 
@@ -134,7 +144,7 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
                if ($message_exists) {
                        if ($parent["id"] != 0) {
                                $existing_message = $message_exists[0];
-                               $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d LIMIT 1",
+                               $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d",
                                        intval($parent["id"]),
                                        dbesc($parent["uri"]),
                                        dbesc($parent_uri),
@@ -144,6 +154,7 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
                }
 
                $arr = array();
+               $arr["network"] = NETWORK_OSTATUS;
                $arr["uri"] = $single_conv->id;
                $arr["plink"] = $single_conv->id;
                $arr["uid"] = $message["uid"];