diff options
author | zotlabs <mike@macgirvin.com> | 2019-06-26 21:54:50 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2019-06-26 21:54:50 -0700 |
commit | d83ce0863abaf448b64c550999e070376fd71b71 (patch) | |
tree | a0f0b45249487bd471bcf0545dfbb23f7b871623 /Zotlabs/Lib/Libzot.php | |
parent | cf844cb27c02c3aae636eb1aa1587b1d5e3e81a0 (diff) | |
parent | 5ccef18d4e5b7901f78a11e0124c16e1c484e3bf (diff) | |
download | volse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.tar.gz volse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.tar.bz2 volse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'Zotlabs/Lib/Libzot.php')
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index de041bd6b..2a13744a3 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2037,7 +2037,7 @@ class Libzot { $item_found = false; $post_id = 0; - $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) + $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) and mid = '%s' and uid = %d limit 1", dbesc($sender), dbesc($sender), @@ -2047,10 +2047,12 @@ class Libzot { ); if($r) { - if($r[0]['author_xchan'] === $sender || $r[0]['owner_xchan'] === $sender || $r[0]['source_xchan'] === $sender) + $stored = $r[0]; + + if($stored['author_xchan'] === $sender || $stored['owner_xchan'] === $sender || $stored['source_xchan'] === $sender) $ownership_valid = true; - $post_id = $r[0]['id']; + $post_id = $stored['id']; $item_found = true; } else { @@ -2074,8 +2076,27 @@ class Libzot { return false; } + if ($stored['resource_type'] === 'event') { + $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($stored['resource_id']), + intval($uid) + ); + if ($i) { + if ($i[0]['event_xchan'] === $sender) { + q("delete from event where event_hash = '%s' and uid = %d", + dbesc($stored['resource_id']), + intval($uid) + ); + } + else { + logger('delete linked event: not owner'); + return; + } + } + } + if($item_found) { - if(intval($r[0]['item_deleted'])) { + if(intval($stored['item_deleted'])) { logger('delete_imported_item: item was already deleted'); if(! $relay) return false; @@ -2087,10 +2108,10 @@ class Libzot { // back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing // this information from the metadata should have no other discernible impact. - if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) { + if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) { q("update item set item_origin = 0 where id = %d and uid = %d", - intval($r[0]['id']), - intval($r[0]['uid']) + intval($stored['id']), + intval($stored['uid']) ); } } |