aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Libzot.php19
-rwxr-xr-xinclude/items.php12
-rw-r--r--include/zot.php19
3 files changed, 49 insertions, 1 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 976ed22fa..ba9ffbead 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2074,6 +2074,25 @@ class Libzot {
return false;
}
+ if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) {
+ $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($item['uuid']),
+ intval($uid)
+ );
+ if ($i) {
+ if ($i[0]['event_xchan'] === $sender) {
+ q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($item['uuid']),
+ intval($uid)
+ );
+ }
+ else {
+ logger('delete linked event: not owner');
+ return;
+ }
+ }
+ }
+
if($item_found) {
if(intval($r[0]['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
diff --git a/include/items.php b/include/items.php
index 95b696034..b6d8eb652 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3740,6 +3740,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if($ok_to_delete) {
+ if ($item['resource_type'] === 'event') {
+ $x = q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($item['resource_id']),
+ intval($item['uid'])
+ );
+ }
+
// set the deleted flag immediately on this item just in case the
// hook calls a remote process which loops. We'll delete it properly in a second.
@@ -3816,7 +3823,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
*/
function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
- $linked_item = (($item['resource_id']) ? true : false);
+ //$linked_item = (($item['resource_id']) ? true : false);
+
+ $linked_resource_types = [ 'photo' ];
+ $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA);
diff --git a/include/zot.php b/include/zot.php
index a37b7cdb5..9dd9aceff 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2278,6 +2278,25 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false;
}
+ if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) {
+ $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($item['uuid']),
+ intval($uid)
+ );
+ if ($i) {
+ if ($i[0]['event_xchan'] === $sender['hash']) {
+ q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($item['uuid']),
+ intval($uid)
+ );
+ }
+ else {
+ logger('delete linked event: not owner');
+ return;
+ }
+ }
+ }
+
require_once('include/items.php');
if($item_found) {