From d0b7723bbcd4e9a4fd5c97370bd1c738fdcdab28 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 3 Aug 2011 16:29:25 -0700 Subject: re-parent api post item with parent_id and no parent_uri --- boot.php | 2 +- mod/item.php | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 5f8402ecd..b306b1402 100644 --- a/boot.php +++ b/boot.php @@ -7,7 +7,7 @@ require_once('include/text.php'); require_once("include/pgettext.php"); -define ( 'FRIENDIKA_VERSION', '2.2.1060' ); +define ( 'FRIENDIKA_VERSION', '2.2.1061' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DB_UPDATE_VERSION', 1076 ); diff --git a/mod/item.php b/mod/item.php index 4b9f3d091..b71c35041 100644 --- a/mod/item.php +++ b/mod/item.php @@ -6,6 +6,8 @@ * text stuff. This function handles status, wall-to-wall status, * local comments, and remote coments - that are posted on this site * (as opposed to being delivered in a feed). + * Also processed here are posts and comments coming through the + * statusnet/twitter API. * All of these become an "item" which is our basic unit of * information. * Posts that originate externally or do not fall into the above @@ -33,6 +35,7 @@ function item_post(&$a) { call_hooks('post_local_start', $_POST); + $api_source = ((x($_POST,'api_source')) ? true : false); /** * Is this a reply to something? @@ -48,22 +51,26 @@ function item_post(&$a) { $r = false; if($parent || $parent_uri) { + + if(! x($_POST,'type')) + $_POST['type'] = 'net-comment'; + if($parent) { $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($parent) ); } elseif($parent_uri && local_user()) { - $_POST['type'] = 'net-comment'; - // This is coming from an API source, we are logged in - // This query will find the immediate parent + // This is coming from an API source, and we are logged in $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($parent_uri), intval(local_user()) ); - // now find the real parent of the conversation - if(count($r)) { - $parid = $r[0]['parent']; + } + // if this isn't the real parent of the conversation, find it + if($r !== false && count($r)) { + $parid = $r[0]['parent']; + if($r[0]['id'] != $r[0]['parent']) { $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", intval($parid) ); @@ -771,12 +778,16 @@ function item_post(&$a) { } logger('post_complete'); + + // figure out how to return, depending on from whence we came + + if($api_source) + return; + if((x($_POST,'return')) && strlen($_POST['return'])) { logger('return: ' . $_POST['return']); goaway($a->get_baseurl() . "/" . $_POST['return'] ); } - if($_POST['api_source']) - return; $json = array('success' => 1); if(x($_POST,'jsreload') && strlen($_POST['jsreload'])) $json['reload'] = $a->get_baseurl() . '/' . $_POST['jsreload']; -- cgit v1.2.3