From ee38b8b699e1faaa468f3a1b8b543293112e0ec0 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 11 Jun 2023 16:41:07 +1000 Subject: [PATCH] groups should not inherit foreign categories. --- include/items.php | 17 +++++++++++++++++ view/tpl/jot.tpl | 1 + 2 files changed, 18 insertions(+) diff --git a/include/items.php b/include/items.php index c0306f801..6dac41507 100644 --- a/include/items.php +++ b/include/items.php @@ -2475,6 +2475,7 @@ function tag_deliver($uid, $item_id) { // and this will be turned into an embedded wall-to-wall post if(perm_is_allowed($uid, $item['author_xchan'], 'post_wall')) { logger('group DM delivery for ' . $u['channel_address']); + $item = filter_categories($item); start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted'])); q("update item set item_blocked = %d where id = %d", intval(ITEM_HIDDEN), @@ -2504,6 +2505,7 @@ function tag_deliver($uid, $item_id) { if ($id == z_root() . '/outbox/' . $u['channel_address']) { if(perm_is_allowed($uid, $item['author_xchan'], 'post_wall')) { logger('group collection delivery for ' . $u['channel_address']); + $item = filter_categories($item); start_delivery_chain($u, $item, $item_id, false, true, (($item['edited'] != $item['created']) || $item['item_deleted'])); q("update item set item_blocked = %d where id = %d", intval(ITEM_HIDDEN), @@ -2737,6 +2739,21 @@ function tag_deliver($uid, $item_id) { } +function filter_categories($item) +{ + $tags = []; + if ($item['term'] && is_array($item['term'])) { + foreach ($item['term'] as $tag) { + if ($tag['ttype'] === TERM_CATEGORY || $tag['ttype'] === TERM_PCATEGORY) { + continue; + } + $tags[] = $tag; + } + $item['term'] = $tags; + } + return $item; +} + /** * @brief This function is called pre-deliver to see if a post matches the criteria to be tag delivered. diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 8c071cd73..f9748fd2c 100644 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -1,3 +1,4 @@ +