From 46d5d4ad630d06466349665cb7df5da5205a619f Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 25 Mar 2024 21:54:03 +1100 Subject: [PATCH] make bang tag exclusive --- include/constants.php | 2 +- include/items.php | 10 +++++----- include/misc.php | 8 ++++---- include/taxonomy.php | 2 +- src/Lib/Activity.php | 4 ++-- src/Module/Ping.php | 2 +- src/Module/Stream.php | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/constants.php b/include/constants.php index 82ed80edb..dcea7febe 100644 --- a/include/constants.php +++ b/include/constants.php @@ -346,7 +346,7 @@ define ( 'TERM_THING', 7 ); define ( 'TERM_BOOKMARK', 8 ); define ( 'TERM_HIERARCHY', 9 ); define ( 'TERM_COMMUNITYTAG', 10 ); -define ( 'TERM_FORUM', 11 ); +define ( 'TERM_GROUP', 11 ); define ( 'TERM_EMOJI', 12 ); define ( 'TERM_QUOTED', 13 ); diff --git a/include/items.php b/include/items.php index 1e2c0bbfd..4b082277d 100644 --- a/include/items.php +++ b/include/items.php @@ -1100,7 +1100,7 @@ function encode_item_xchan($xchan) { function encode_item_terms($terms,$mirror = false) { $ret = []; - $allowed_export_terms = [TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK, TERM_COMMUNITYTAG, TERM_FORUM]; + $allowed_export_terms = [TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK, TERM_COMMUNITYTAG, TERM_GROUP]; if($mirror) { $allowed_export_terms[] = TERM_PCATEGORY; @@ -1199,7 +1199,7 @@ function decode_tags($t) { $tag['ttype'] = TERM_COMMUNITYTAG; break; case 'forum': - $tag['ttype'] = TERM_FORUM; + $tag['ttype'] = TERM_GROUP; break; default: case 'unknown': @@ -2674,7 +2674,7 @@ function tag_deliver($uid, $item_id) { */ - $terms = ((isset($item['term'])) ? get_terms_oftype($item['term'],[TERM_MENTION, TERM_FORUM]) : false); + $terms = ((isset($item['term'])) ? get_terms_oftype($item['term'],[TERM_MENTION, TERM_GROUP]) : false); $pterms = ((isset($item['term'])) ? get_terms_oftype($item['term'], [TERM_PCATEGORY, TERM_HASHTAG] ) : false); @@ -2745,7 +2745,7 @@ function tag_deliver($uid, $item_id) { */ if ($is_group && intval($item['item_thread_top']) && (! intval($item['item_wall']))) { - if ((intval($term['ttype']) === TERM_FORUM || get_pconfig($uid,'system','post_via_mentions',in_array($role,['forum','forum_moderated']))) && perm_is_allowed($uid, $item['author_xchan'], 'post_wall')) { + if ((intval($term['ttype']) === TERM_GROUP || get_pconfig($uid,'system','post_via_mentions',in_array($role,['forum','forum_moderated']))) && perm_is_allowed($uid, $item['author_xchan'], 'post_wall')) { logger('group mention delivery for ' . $u['channel_address']); 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", @@ -2948,7 +2948,7 @@ function i_am_mentioned($channel,$item,$check_groups = false) { $tagged = false; $matches = []; - $tagtype = $check_groups ? TERM_FORUM : TERM_MENTION; + $tagtype = $check_groups ? TERM_GROUP : TERM_MENTION; $terms = ((isset($item['term'])) ? get_terms_oftype($item['term'], $tagtype) : false); if ($terms) { diff --git a/include/misc.php b/include/misc.php index 10cd32e2b..2e06899e4 100644 --- a/include/misc.php +++ b/include/misc.php @@ -2967,7 +2967,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $termtype = ((str_starts_with($tag, '#')) ? TERM_HASHTAG : TERM_UNKNOWN); $termtype = ((str_starts_with($tag, '"#')) ? TERM_HASHTAG : $termtype); $termtype = ((str_starts_with($tag, '@')) ? TERM_MENTION : $termtype); - $termtype = ((str_starts_with($tag, '!')) ? TERM_FORUM : $termtype); + $termtype = ((str_starts_with($tag, '!')) ? TERM_GROUP : $termtype); // Is it a hashtag of some kind? @@ -3035,7 +3035,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) // BEGIN mentions - if (in_array($termtype, [TERM_MENTION, TERM_FORUM])) { + if (in_array($termtype, [TERM_MENTION, TERM_GROUP])) { // The @! tag will alter permissions // $in_network is set to false to avoid false positives on posts originating @@ -3159,7 +3159,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) } // add the channel's xchan_hash to $access_tag if exclusive - if ($exclusive) { + if (($termtype === TERM_GROUP) || $exclusive) { $access_tag = 'cid:' . $xc['xchan_hash']; } @@ -3173,7 +3173,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $zrl = isOWAEnabled($url) ? 'zrl' : 'url'; - if ($termtype === TERM_FORUM) { + if ($termtype === TERM_GROUP) { $newtag = '!' . (($exclusive) ? '!' : '') . '[' . $zrl . '=' . $profile . ']' . $newname . '[/' . $zrl . ']'; $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } diff --git a/include/taxonomy.php b/include/taxonomy.php index a47ca4b01..1eb792572 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -165,7 +165,7 @@ function format_term_for_display($term) $s = ''; if (($term['ttype'] == TERM_HASHTAG) || ($term['ttype'] == TERM_COMMUNITYTAG)) { $s .= '#'; - } elseif ($term['ttype'] == TERM_FORUM) { + } elseif ($term['ttype'] == TERM_GROUP) { $s .= '!'; } elseif ($term['ttype'] == TERM_MENTION) { $s .= '@'; diff --git a/src/Lib/Activity.php b/src/Lib/Activity.php index 017f709d4..bb03e6c1a 100644 --- a/src/Lib/Activity.php +++ b/src/Lib/Activity.php @@ -516,7 +516,7 @@ class Activity case 'Mention': $mention_type = substr($t['name'], 0, 1); if ($mention_type === '!') { - $ret[] = ['ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; + $ret[] = ['ttype' => TERM_GROUP, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; } else { $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((str_starts_with($t['name'], '@')) ? substr($t['name'], 1) : $t['name'])]; } @@ -563,7 +563,7 @@ class Activity } break; - case TERM_FORUM: + case TERM_GROUP: $term = self::lookup_term_addr($t['url'], $t['term']); $ret[] = ['type' => 'Mention', 'href' => $t['url'], 'name' => '!' . (($term) ?: $t['term'])]; break; diff --git a/src/Module/Ping.php b/src/Module/Ping.php index 78d97b564..2e193d5eb 100644 --- a/src/Module/Ping.php +++ b/src/Module/Ping.php @@ -800,7 +800,7 @@ class Ping extends Controller $forums['total'] = 0; for ($x = 0; $x < $fcount; $x++) { - $ttype = TERM_FORUM; + $ttype = TERM_GROUP; $p = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . protect_sprintf(dbesc($forums[$x]['xchan_name'])) . "'"); $p = ids_to_querystr($p, 'parent'); diff --git a/src/Module/Stream.php b/src/Module/Stream.php index 671ddfb5e..87a220d70 100644 --- a/src/Module/Stream.php +++ b/src/Module/Stream.php @@ -331,7 +331,7 @@ class Stream extends Controller $p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal "); $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype in (%d, %d) AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'", intval(TERM_MENTION), - intval(TERM_FORUM) + intval(TERM_GROUP) ); $p_str = ids_to_querystr(array_merge($p1, $p2), 'parent');