From c2ce1d988136c848c1b0cbad5ffdddacca82901d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 9 Oct 2024 22:43:01 +0200 Subject: containers: send add in mod like, send remove on delete --- Zotlabs/Lib/Activity.php | 26 +++++++++++++++++++++++--- Zotlabs/Lib/Libzot.php | 2 -- Zotlabs/Module/Item.php | 5 +++-- Zotlabs/Module/Like.php | 7 ++++++- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index dfbdacf18..f10a2bace 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -846,12 +846,32 @@ class Activity { $ret['type'] = self::activity_mapper($i['verb']); if ((isset($i['item_deleted']) && intval($i['item_deleted'])) && !$recurse) { - $is_response = false; - if (ActivityStreams::is_response_activity($ret['type'])) { + if ($i['verb'] === 'Add' && str_contains($i['tgt_type'], 'Collection')) { + $ret['id'] = str_replace('/item/', '/activity/', $i['mid']) . '#Remove'; + $ret['type'] = 'Remove'; + if (is_string($i['obj'])) { + $obj = json_decode($i['obj'], true); + } + elseif(is_array($i['obj'])) { + $obj = $i['obj']; + } + if (isset($obj['id'])) { + $ret['object'] = $obj['id']; + } + else { + $ret['object'] = str_replace('/item/', '/activity/', $i['mid']); + } + $ret['target'] = is_array($i['target']) ? $i['target'] : json_decode($i['target'], true); + + return $ret; + } + + $is_response = ActivityStreams::is_response_activity($ret['type']); + + if ($is_response) { $ret['type'] = 'Undo'; $fragment = 'undo'; - $is_response = true; } else { $ret['type'] = 'Delete'; diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 5c0b620eb..3f339a21a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1966,8 +1966,6 @@ class Libzot { if (post_is_importable($arr['uid'], $arr, $abook)) { $item_result = item_store($arr, addAndSync: false); - - if ($item_result['success']) { $item_id = $item_result['item_id']; diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 0b50b9b55..1dd3017aa 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1312,6 +1312,7 @@ class Item extends Controller { } $post_id = $post['item_id']; + $approval_id = $post['approval_id'] ?? 0; $datarray = $post['item']; @@ -1408,8 +1409,8 @@ class Item extends Controller { if (!$nopush) { Master::Summon(['Notifier', $notify_type, $post_id]); - if (!empty($post['approval_id'])) { - Master::Summon(['Notifier', $notify_type, $post['approval_id']]); + if ($approval_id) { + Master::Summon(['Notifier', $notify_type, $approval_id]); } } diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index d493742e7..1308beef7 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -559,6 +559,7 @@ class Like extends Controller { $post = item_store($arr); $post_id = $post['item_id']; + $approval_id = $post['approval_id'] ?? 0; // save the conversation from expiration @@ -609,7 +610,11 @@ class Like extends Controller { } - Master::Summon(array('Notifier', 'like', $post_id)); + Master::Summon(['Notifier', 'like', $post_id]); + if ($approval_id) { + Master::Summon(['Notifier', 'like', $approval_id]); + } + if ($interactive) { notice(t('Action completed.') . EOL); -- cgit v1.2.3