fix some conflicts between private tags and forum tags
This commit is contained in:
parent
458f2e748d
commit
1ac35dd047
@ -2571,18 +2571,22 @@ function tag_deliver($uid, $item_id) {
|
||||
if($terms)
|
||||
logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA);
|
||||
|
||||
|
||||
$max_forums = get_config('system','max_tagged_forums',2);
|
||||
$matched_forums = 0;
|
||||
|
||||
|
||||
$link = normalise_link($u[0]['xchan_url']);
|
||||
|
||||
|
||||
if($terms) {
|
||||
foreach($terms as $term) {
|
||||
if(link_compare($term['url'],$link)) {
|
||||
$mention = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(! link_compare($term['url'],$link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($mention) {
|
||||
$mention = true;
|
||||
|
||||
logger('Mention found for ' . $u[0]['channel_name']);
|
||||
|
||||
$r = q("update item set item_mentionsme = 1 where id = %d",
|
||||
@ -2593,9 +2597,7 @@ function tag_deliver($uid, $item_id) {
|
||||
// Now let's check if this mention was inside a reshare so we don't spam a forum
|
||||
// If it's private we may have to unobscure it momentarily so that we can parse it.
|
||||
|
||||
$body = $item['body'];
|
||||
|
||||
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
|
||||
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
|
||||
|
||||
$tagged = false;
|
||||
$plustagged = false;
|
||||
@ -2614,16 +2616,12 @@ function tag_deliver($uid, $item_id) {
|
||||
|
||||
$found = false;
|
||||
|
||||
$max_forums = get_config('system','max_tagged_forums');
|
||||
if(! $max_forums)
|
||||
$max_forums = 2;
|
||||
$matched_forums = 0;
|
||||
$matches = array();
|
||||
|
||||
if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
|
||||
foreach($matches as $match) {
|
||||
$matched_forums ++;
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2]) {
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) {
|
||||
if($matched_forums <= $max_forums) {
|
||||
$plustagged = true;
|
||||
$found = true;
|
||||
@ -2637,7 +2635,7 @@ function tag_deliver($uid, $item_id) {
|
||||
if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
|
||||
foreach($matches as $match) {
|
||||
$matched_forums ++;
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2]) {
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) {
|
||||
if($matched_forums <= $max_forums) {
|
||||
$plustagged = true;
|
||||
$found = true;
|
||||
@ -2650,7 +2648,7 @@ function tag_deliver($uid, $item_id) {
|
||||
|
||||
if(! ($tagged || $plustagged)) {
|
||||
logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring');
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
$arr = [
|
||||
@ -2685,20 +2683,20 @@ function tag_deliver($uid, $item_id) {
|
||||
|
||||
if(! $plustagged) {
|
||||
logger('Not a plus tag', LOGGER_DEBUG);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
// plustagged - keep going, next check permissions
|
||||
|
||||
if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) {
|
||||
logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if((! $mention) && (! $union)) {
|
||||
logger('No mention for ' . $u[0]['channel_name'] . ' and no union.');
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
// tgroup delivery - setup a second delivery chain
|
||||
@ -2708,11 +2706,14 @@ function tag_deliver($uid, $item_id) {
|
||||
|
||||
if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
|
||||
logger('Item was local or a comment. rejected.');
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
logger('Creating second delivery chain.');
|
||||
start_delivery_chain($u[0],$item,$item_id,null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2760,50 +2761,40 @@ function tgroup_check($uid, $item) {
|
||||
if($terms)
|
||||
logger('tgroup_check: post mentions: ' . print_r($terms,true), LOGGER_DATA);
|
||||
|
||||
$max_forums = get_config('system','max_tagged_forums',2);
|
||||
$matched_forums = 0;
|
||||
|
||||
$link = normalise_link($u[0]['xchan_url']);
|
||||
|
||||
if($terms) {
|
||||
foreach($terms as $term) {
|
||||
if(link_compare($term['url'],$link)) {
|
||||
$mention = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(! link_compare($term['url'],$link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($mention) {
|
||||
$mention = true;
|
||||
logger('tgroup_check: mention found for ' . $u[0]['channel_name']);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
// At this point we've determined that the person receiving this post was mentioned in it.
|
||||
// Now let's check if this mention was inside a reshare so we don't spam a forum
|
||||
// note: $term has been set to the matching term
|
||||
|
||||
|
||||
$body = $item['body'];
|
||||
|
||||
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
|
||||
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
|
||||
|
||||
|
||||
$pluspattern = '/@\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\+\[\/zrl\]/';
|
||||
|
||||
$forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
|
||||
|
||||
|
||||
$found = false;
|
||||
|
||||
$max_forums = get_config('system','max_tagged_forums');
|
||||
if(! $max_forums)
|
||||
$max_forums = 2;
|
||||
$matched_forums = 0;
|
||||
$matches = array();
|
||||
|
||||
if(preg_match_all($pluspattern,$body,$matches,PREG_SET_ORDER)) {
|
||||
foreach($matches as $match) {
|
||||
$matched_forums ++;
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2]) {
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_MENTION) {
|
||||
if($matched_forums <= $max_forums) {
|
||||
$found = true;
|
||||
break;
|
||||
@ -2816,7 +2807,7 @@ function tgroup_check($uid, $item) {
|
||||
if(preg_match_all($forumpattern,$body,$matches,PREG_SET_ORDER)) {
|
||||
foreach($matches as $match) {
|
||||
$matched_forums ++;
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2]) {
|
||||
if($term['url'] === $match[1] && $term['term'] === $match[2] && intval($term['ttype']) === TERM_FORUM) {
|
||||
if($matched_forums <= $max_forums) {
|
||||
$found = true;
|
||||
break;
|
||||
@ -2828,11 +2819,16 @@ function tgroup_check($uid, $item) {
|
||||
|
||||
if(! $found) {
|
||||
logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring');
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sourced and tag-delivered posts are re-targetted for delivery to the connections of the channel
|
||||
|
Reference in New Issue
Block a user