aboutsummaryrefslogtreecommitdiffstats
path: root/include/connections.php
diff options
context:
space:
mode:
authorManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-05-19 13:25:00 +0200
committerManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-05-19 13:25:00 +0200
commit429140df97a2c273fba6974147ac2e48e7688263 (patch)
tree2e337542da1b0f4c9c383dfeb8a7d9eb63990a72 /include/connections.php
parentf92d2e3f7c6573bd7bab04223c7e28662605c6d8 (diff)
parentaf2b263bc74b16601ec7c123a58f0549613aed27 (diff)
downloadvolse-hubzilla-429140df97a2c273fba6974147ac2e48e7688263.tar.gz
volse-hubzilla-429140df97a2c273fba6974147ac2e48e7688263.tar.bz2
volse-hubzilla-429140df97a2c273fba6974147ac2e48e7688263.zip
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'include/connections.php')
-rw-r--r--include/connections.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/include/connections.php b/include/connections.php
index d97ea3887..e942503f0 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -373,19 +373,46 @@ function contact_remove($channel_id, $abook_id) {
if(intval($abook['abook_self']))
return false;
- $r = q("select id from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d and item_retained = 0 and item_starred = 0",
+ $r = q("select id, parent from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d and item_retained = 0 and item_starred = 0",
dbesc($abook['abook_xchan']),
dbesc($abook['abook_xchan']),
intval($channel_id)
);
if($r) {
+ $already_saved = [];
foreach($r as $rr) {
- $x = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
+ $w = $x = $y = null;
+
+ // optimise so we only process newly seen parent items
+ if (in_array($rr['parent'],$already_saved)) {
+ continue;
+ }
+ // if this isn't the parent, fetch the parent's item_retained and item_starred to see if the conversation
+ // should be retained
+ if($rr['id'] != $rr['parent']) {
+ $w = q("select id, item_retained, item_starred from item where id = %d",
+ intval($rr['parent'])
+ );
+ if($w) {
+ // see if the conversation was filed
+ $x = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
+ intval(TERM_OBJ_POST),
+ intval($w[0]['id']),
+ intval(TERM_FILE)
+ );
+ if (intval($w[0]['item_retained']) || intval($w[0]['item_starred']) || $x) {
+ $already_saved[] = $rr['parent'];
+ continue;
+ }
+ }
+ }
+ // see if this item was filed
+ $y = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
intval(TERM_OBJ_POST),
intval($rr['id']),
intval(TERM_FILE)
);
- if($x) {
+ if ($y) {
continue;
}
drop_item($rr['id'],false);