aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-03-23 20:11:18 +0000
committerMario <mario@mariovavti.com>2023-03-23 20:11:18 +0000
commit2c483c460a2d5c806b9e62097673ad237e6b154a (patch)
tree811998820caebf68be26eb471c6f218ec2039992 /include
parent5c755fdd1c41538c243a428bb72aa2bd62ff105f (diff)
downloadvolse-hubzilla-2c483c460a2d5c806b9e62097673ad237e6b154a.tar.gz
volse-hubzilla-2c483c460a2d5c806b9e62097673ad237e6b154a.tar.bz2
volse-hubzilla-2c483c460a2d5c806b9e62097673ad237e6b154a.zip
initial check in to allow all mentions option
Diffstat (limited to 'include')
-rw-r--r--include/items.php42
-rw-r--r--include/taxonomy.php9
2 files changed, 42 insertions, 9 deletions
diff --git a/include/items.php b/include/items.php
index b795df90d..a7d07a599 100644
--- a/include/items.php
+++ b/include/items.php
@@ -143,11 +143,8 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
}
- // Forward to thread listeners and pubstream (sys channel), *unless* there is even
- // a remote hint that the item might have some privacy attached.
- // This could be (for instance) an ActivityPub DM
- // in the middle of a public thread. Unless we can guarantee beyond all doubt that
- // this is public, don't allow it to go to thread listeners.
+ // Forward to thread listeners and pubstream (sys channel),
+ // *unless* there is even a remote hint that the item might have some privacy attached.
if(!intval($item['item_private'])) {
$sys = get_sys_channel();
@@ -212,6 +209,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
$recipients[] = $item['owner_xchan'];
}
+
return $recipients;
}
@@ -3043,6 +3041,40 @@ function tgroup_check($uid, $item) {
}
+
+function i_am_mentioned($channel, $item, $check_groups = false) {
+
+ $link = z_root() . '/channel/' . $channel['channel_address'];
+
+ $body = preg_replace('/\[share(.*?)\[\/share]/','',$item['body']);
+
+ $tagged = false;
+ $matches = [];
+ $tagtype = $check_groups ? TERM_FORUM : TERM_MENTION;
+ $terms = ((isset($item['term'])) ? get_terms_oftype($item['term'], $tagtype) : false);
+
+ if ($terms) {
+ foreach ($terms as $term) {
+ if ($link === $term['url']) {
+ $pattern = '/[!@]!?\[[uz]rl=' . preg_quote($term['url'],'/') . '](.*?)\[\/[uz]rl]/';
+ if (preg_match($pattern,$body,$matches)) {
+ $tagged = true;
+ }
+ $pattern = '/\[[uz]rl=' . preg_quote($term['url'],'/') . '][!@](.*?)\[\/[uz]rl]/';
+ if (preg_match($pattern,$body,$matches)) {
+ $tagged = true;
+ }
+ }
+ }
+ }
+ $unless = intval(get_pconfig($channel['channel_id'], 'system', 'unless_mention_count', get_config('system', 'unless_mention_count', 20)));
+ if ($unless && $terms && count($terms) > $unless) {
+ $tagged = false;
+ }
+ return $tagged;
+}
+
+
/**
* Sourced and tag-delivered posts are re-targetted for delivery to the connections of the channel
* receiving the post. This starts the second delivery chain, by resetting permissions and ensuring
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 671f96c2e..3f6db50d1 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -119,13 +119,14 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
}
-function get_terms_oftype($arr,$type) {
- $ret = array();
- if(! (is_array($arr) && count($arr)))
+function get_terms_oftype($arr, $type) {
+ $ret = [];
+
+ if(!is_array($arr) && count($arr))
return $ret;
if(! is_array($type))
- $type = array($type);
+ $type = [$type];
foreach($type as $t)
foreach($arr as $x)