From 00888a73bb7666a7b082e84f3c7edb2a42d86543 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 3 Mar 2013 17:58:35 +0100 Subject: [PATCH] OStatus conversation: Prevent posting loops --- include/ostatus_conversation.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/ostatus_conversation.php b/include/ostatus_conversation.php index cecbb0496..36ba207ab 100644 --- a/include/ostatus_conversation.php +++ b/include/ostatus_conversation.php @@ -1,5 +1,6 @@ time()) { - logger('complete_conversation: poll intervall not reached'); + logger('complete_conversation: poll interval not reached'); return; } } logger('complete_conversation: cron_start'); - $start = date("Y-m-d H:i:s", time() - 86400); + $start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60)); $conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'", dbesc($start)); foreach ($conversations AS $conversation) { @@ -100,18 +109,18 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio else $parent_uri = $parent["uri"]; - if ($parent["id"] != 0) { - $message_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", + $message_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", intval($message["uid"]), dbesc($single_conv->id)); - if ($message_exists) { + 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", intval($parent["id"]), dbesc($parent["uri"]), dbesc($parent_uri), intval($existing_message["id"])); - continue; } + continue; } $arr = array();