aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/api.php2
-rwxr-xr-xinclude/items.php67
2 files changed, 67 insertions, 2 deletions
diff --git a/include/api.php b/include/api.php
index cee1fde23..09cca8d8d 100644
--- a/include/api.php
+++ b/include/api.php
@@ -565,7 +565,7 @@
if(requestdata('lat') && requestdata('long'))
$_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
$_REQUEST['profile_uid'] = local_user();
-// if(requestdata('parent'))
+
if($parent)
$_REQUEST['type'] = 'net-comment';
else {
diff --git a/include/items.php b/include/items.php
index 7d51261db..e19d729ba 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2148,6 +2148,67 @@ function local_delivery($importer,$data) {
}
if($deleted) {
+ // check for relayed deletes to our conversation
+
+ $is_reply = false;
+ $r = q("select * from item where uri = '%s' and uid = %d limit 1",
+ dbesc($uri),
+ intval($importer['importer_uid'])
+ );
+ if(count($r)) {
+ $parent_uri = $r[0]['parent-uri'];
+ if($r[0]['id'] != $r[0]['parent'])
+ $is_reply = true;
+ }
+
+ if($is_reply) {
+ $community = false;
+
+ if($importer['page-flags'] == PAGE_COMMUNITY || $importer['page-flags'] == PAGE_PRVGROUP ) {
+ $sql_extra = '';
+ $community = true;
+ logger('local_delivery: possible community delete');
+ }
+ else
+ $sql_extra = " and contact.self = 1 and item.wall = 1 ";
+
+ // was the top-level post for this reply written by somebody on this site?
+ // Specifically, the recipient?
+
+ $is_a_remote_delete = false;
+
+ $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
+ `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
+ LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
+ AND `item`.`uid` = %d
+ $sql_extra
+ LIMIT 1",
+ dbesc($parent_uri),
+ dbesc($parent_uri),
+ dbesc($parent_uri),
+ intval($importer['importer_uid'])
+ );
+ if($r && count($r))
+ $is_a_remote_delete = true;
+
+ // Does this have the characteristics of a community or private group comment?
+ // If it's a reply to a wall post on a community/prvgroup page it's a
+ // valid community comment. Also forum_mode makes it valid for sure.
+ // If neither, it's not.
+
+ if($is_a_remote_delete && $community) {
+ if((! $r[0]['forum_mode']) && (! $r[0]['wall'])) {
+ $is_a_remote_delete = false;
+ logger('local_delivery: not a community delete');
+ }
+ }
+
+ if($is_a_remote_delete) {
+ logger('local_delivery: received remote delete');
+ }
+ }
+
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id`
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri),
@@ -2235,7 +2296,11 @@ function local_delivery($importer,$data) {
);
}
}
- }
+ // if this is a relayed delete, propagate it to other recipients
+
+ if($is_a_remote_delete)
+ proc_run('php',"include/notifier.php","drop",$item['id']);
+ }
}
}
}