From 2c483c460a2d5c806b9e62097673ad237e6b154a Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Mar 2023 20:11:18 +0000 Subject: initial check in to allow all mentions option --- Zotlabs/Module/Item.php | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 5ca94cd76..b3b040e96 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1194,12 +1194,15 @@ class Item extends Controller { (($remote_id) ? $remote_id : basename($datarray['mid'])), true); } - if ($orig_post) { $datarray['id'] = $post_id; $x = item_store_update($datarray, $execflag); + if ($x['success']) { + $this->add_listeners($datarray); + } + // We only need edit activities for other federated protocols // which do not support edits natively. While this does federate // edits, it presents a number of issues locally - such as #757 and #758. @@ -1238,6 +1241,10 @@ class Item extends Controller { $post = item_store($datarray, $execflag); + if ($post['success']) { + $this->add_listeners($datarray); + } + $post_id = $post['item_id']; $datarray = $post['item']; @@ -1603,4 +1610,33 @@ class Item extends Controller { } + function add_listeners($item) { + // ONLY public items! + if ($item['item_thread_top'] && !$item['item_private'] && !empty($item['term'])) { + foreach($item['term'] as $t) { + if (empty($t['url']) || $t['ttype'] != TERM_MENTION || $t['otype'] != TERM_OBJ_POST) { + continue; + } + + $listener = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_deleted = 0 order by hubloc_id desc", + dbesc($t['url']) + ); + + if ($listener) { + $listener = Libzot::zot_record_preferred($listener); + + $c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s'", + intval($profile_uid), + dbesc($listener['hubloc_hash']) + ); + + if (!$c) { + ThreadListener::store($item['mid'], $listener['hubloc_hash']); + } + } + } + } + } + + } -- cgit v1.2.3