From: Michael Vogel Date: Fri, 27 Jun 2014 05:59:00 +0000 (+0200) Subject: appnet, statusnet: Posts from unknown contacts weren't posted X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=commitdiff_plain;h=f0efa3cae2ce1f3e6ed9a2b016abe96f0ce1b75d appnet, statusnet: Posts from unknown contacts weren't posted --- diff --git a/appnet/appnet.php b/appnet/appnet.php index 4bf72da5..62b66c32 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -825,13 +825,15 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th if (isset($post["reply_to"]) AND ($post["reply_to"] != "")) { $postarray['thr-parent'] = "adn::".$post["reply_to"]; - // Complete the thread if the parent doesn't exists + // Complete the thread (if the parent doesn't exists) if ($threadcompletion) { - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", - dbesc($postarray['thr-parent']), - intval($uid) - ); - if (!count($r)) { + //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + // dbesc($postarray['thr-parent']), + // intval($uid) + // ); + //if (!count($r)) { + logger("appnet_createpost: completing thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG); + require_once("addon/appnet/AppDotNet.php"); $token = get_pconfig($uid,'appnet','token'); @@ -850,11 +852,15 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th logger("appnet_createpost: Error fetching thread for user ".$uid." ".appnet_error($e->getMessage())); } $thread = array_reverse($thread); + + logger("appnet_createpost: fetched ".count($thread)." items for thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG); + foreach ($thread AS $tpost) { $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false); $item = item_store($threadpost); + logger("appnet_createpost: stored post ".$post["id"]." thread ".$post["thread_id"]." in item ".$item, LOGGER_DEBUG); } - } + //} } // Don't create accounts of people who just comment something $createuser = false; @@ -1042,10 +1048,10 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { intval($uid), dbesc("adn::".$contact["id"])); if(!count($r) AND !$create_user) - return($me); + return($me["id"]); if ($contact["canonical_url"] == "") - return($me); + return($me["id"]); if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) { logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 2f3f84d2..38381ef3 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1394,7 +1394,7 @@ function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $ $posts = array_reverse($items); foreach($posts AS $post) { - $postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true); + $postarray = statusnet_createpost($a, $uid, $post, $self, false, false); if (trim($postarray['body']) == "") continue;