aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Libzot.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-05 11:47:22 +0000
committerMario <mario@mariovavti.com>2020-10-05 11:47:22 +0000
commit244c8edfca6cc7ab48c337bda37ab70bfe819413 (patch)
tree3f35f96d478b51df7c310b956f5bf6fde00f9e0c /Zotlabs/Lib/Libzot.php
parent245c0c22cdc1ed7f3e06850295487205a8e5a4a5 (diff)
downloadvolse-hubzilla-244c8edfca6cc7ab48c337bda37ab70bfe819413.tar.gz
volse-hubzilla-244c8edfca6cc7ab48c337bda37ab70bfe819413.tar.bz2
volse-hubzilla-244c8edfca6cc7ab48c337bda37ab70bfe819413.zip
Ãrework undo/delete to use inline objects
Diffstat (limited to 'Zotlabs/Lib/Libzot.php')
-rw-r--r--Zotlabs/Lib/Libzot.php45
1 files changed, 17 insertions, 28 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index ab322ca86..f16f5258a 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1202,10 +1202,6 @@ class Libzot {
if(in_array($env['type'],['activity','response'])) {
- $arr = Activity::decode_note($AS);
-
- //logger($AS->debug());
-
$r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' ",
dbesc($AS->actor['id'])
);
@@ -1727,7 +1723,7 @@ class Libzot {
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
- $item_id = self::delete_imported_item($sender,$arr,$channel['channel_id'],$relay);
+ $item_id = self::delete_imported_item($sender,$act,$arr,$channel['channel_id'],$relay);
$DR->update(($item_id) ? 'deleted' : 'delete_failed');
$result[] = $DR->get();
@@ -2110,7 +2106,7 @@ class Libzot {
* @return boolean|int post_id
*/
- static function delete_imported_item($sender, $item, $uid, $relay) {
+ static function delete_imported_item($sender, $act, $item, $uid, $relay) {
logger('invoked', LOGGER_DEBUG);
@@ -2118,46 +2114,39 @@ class Libzot {
$item_found = false;
$post_id = 0;
- $m = parse_url($item['mid']);
- unset($m['fragment']);
- $normalised = unparse_url($m);
+ if ($item['verb'] === 'Tombstone') {
+ // The id of the deleted thing is the item mid (activity id)
+ $mid = $item['mid'];
+ }
+ else {
+ // The id is the object id if the type is Undo or Delete
+ $mid = ((is_array($act->obj)) ? $act->obj['id'] : $act->obj);
+ }
- // reactions such as like and dislike could have an mid with /activity/ in it.
- // Check for both forms in order to prevent duplicates.
+ // we may have stored either the object id or the activity id if it was a response activity (like, dislike, etc.)
$r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid IN ('%s', '%s') and uid = %d limit 1",
dbesc($sender),
dbesc($sender),
dbesc($sender),
- dbesc($normalised),
- dbesc(str_replace('/activity/', '/item/', $normalised)),
+ dbesc($mid),
+ dbesc(str_replace('/activity/','/item/',$mid)),
intval($uid)
);
if($r) {
$stored = $r[0];
- if($stored['author_xchan'] === $sender || $stored['owner_xchan'] === $sender || $stored['source_xchan'] === $sender)
- $ownership_valid = true;
+ // we proved ownership in the sql query
+ $ownership_valid = true;
$post_id = $stored['id'];
$item_found = true;
}
else {
-
- // perhaps the item is still in transit and the delete notification got here before the actual item did. Store it with the deleted flag set.
- // item_store() won't try to deliver any notifications or start delivery chains if this flag is set.
- // This means we won't end up with potentially even more delivery threads trying to push this delete notification.
- // But this will ensure that if the (undeleted) original post comes in at a later date, we'll reject it because it will have an older timestamp.
-
- logger('delete received for non-existent item - storing item data.');
-
- if($item['author_xchan'] === $sender || $item['owner_xchan'] === $sender || $item['source_xchan'] === $sender) {
- $ownership_valid = true;
- $item_result = item_store($item);
- $post_id = $item_result['item_id'];
- }
+ // this will fail with an ownership issue, so explain the real reason
+ logger('delete received for non-existent item or not owned by sender - ignoring.');
}
if($ownership_valid === false) {