aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rw-r--r--include/items.php42
1 files changed, 37 insertions, 5 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