From a47aae22d0e1597b91e2997e2e0ccbba263263c2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 2 Dec 2018 21:51:45 -0800 Subject: [PATCH] more work on zap missing parents --- Zotlabs/Lib/Libzot.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 8becc1a71..abb1337ba 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1537,6 +1537,8 @@ class Libzot { $DR->update('comment parent not found'); $result[] = $DR->get(); + $fetch_ap = false; + // We don't seem to have a copy of this conversation or at least the parent // - so request a copy of the entire conversation to date. // Don't do this if it's a relay post as we're the ones who are supposed to @@ -1557,13 +1559,24 @@ class Libzot { if($f === false) { // This might be an ActivityPub conversation and not a Zot6 conversation. Activity::fetch_and_store_parents($channel,$sender,null,$arr); + $fetch_ap = true; } } - continue; + if($fetch_ap) { + // If we're fetching via activitypub we won't have stored the current item + // check again for existence and if we now have a parent, continue so we can store it + + $fap = q("select route, id, parent_mid, mid, owner_xchan, item_private from item where mid = '%s' and uid = %d limit 1", + dbesc($arr['parent_mid']), + intval($channel['channel_id']) + ); + } + if(! $fap) { + continue; + } + $r = $fap; } - - if($relay || $friendofriend || (intval($r[0]['item_private']) === 0 && intval($arr['item_private']) === 0)) { // reset the route in case it travelled a great distance upstream // use our parent's route so when we go back downstream we'll match