issues with language filtering

This commit is contained in:
zotlabs 2018-12-11 15:57:15 -08:00
parent 0a2eae6612
commit 50ad168ad0
5 changed files with 24 additions and 30 deletions

View file

@ -1603,11 +1603,9 @@ class Activity {
}
if($abook) {
if(! post_is_importable($s,$abook[0])) {
logger('post is filtered');
return;
}
if(! post_is_importable($channel['channel_id'],$s,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {
@ -2139,13 +2137,11 @@ class Activity {
intval($channel['channel_id'])
);
if($abook) {
if(! post_is_importable($item,$abook[0])) {
logger('post is filtered');
return;
}
}
if(! post_is_importable($channel['channel_id'],$item,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {
set_iconfig($item,'ostatus','conversation',$act->obj['conversation'],1);
@ -2374,11 +2370,9 @@ class Activity {
intval($channel['channel_id'])
);
if($abook) {
if(! post_is_importable($s,$abook[0])) {
logger('post is filtered');
return;
}
if(! post_is_importable($channel['channel_id'],$s,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {

View file

@ -1666,7 +1666,7 @@ class Libzot {
elseif($arr['edited'] > $r[0]['edited']) {
$arr['id'] = $r[0]['id'];
$arr['uid'] = $channel['channel_id'];
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($channel['channel_id'],$arr,$abook))) {
$DR->update('update ignored');
$result[] = $DR->get();
}
@ -1706,7 +1706,7 @@ class Libzot {
$item_id = 0;
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr['uid'],$arr,$abook))) {
$DR->update('post ignored');
$result[] = $DR->get();
}

View file

@ -16,10 +16,9 @@ class MessageFilter {
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text);
$lang = null;
if((strpos($incl,'lang=') !== false) || (strpos($excl,'lang=') !== false)) {
if((strpos($incl,'lang=') !== false) || (strpos($excl,'lang=') !== false) || (strpos($incl,'lang!=') !== false) || (strpos($excl,'lang!=') !== false)) {
$lang = detect_language($text);
}

View file

@ -1338,7 +1338,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
}
if(! post_is_importable($datarray, $contact))
if(! post_is_importable($importer['channel_id'],$datarray, $contact))
continue;
$datarray['parent_mid'] = $datarray['mid'];
@ -1494,7 +1494,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
}
if(! post_is_importable($datarray, $contact))
if(! post_is_importable($importer['channel_id'],$datarray, $contact))
continue;
logger('author: ' . print_r($author, true), LOGGER_DEBUG);

View file

@ -3261,25 +3261,26 @@ function check_item_source($uid, $item) {
return false;
}
function post_is_importable($item,$abook) {
function post_is_importable($channel_id,$item,$abook) {
if(! $abook)
return true;
if(! $item)
return false;
$incl = PConfig::get($abook['abook_channel'],'system','message_filter_incl',EMPTY_STR);
$excl = PConfig::get($abook['abook_channel'],'system','message_filter_excl',EMPTY_STR);
$incl = PConfig::get($channel_id,'system','message_filter_incl',EMPTY_STR);
$excl = PConfig::get($channel_id,'system','message_filter_excl',EMPTY_STR);
if($incl || $excl) {
$x = MessageFilter::evaluate($item,$incl,$excl);
if(! $x) {
logger('MessageFilter: channel blocked content',LOGGER_DEBUG,LOG_INFO);
return false;
}
}
if(($abook['abook_channel']) && (! feature_enabled($abook['abook_channel'],'connfilter')))
if(($channel_id) && (! feature_enabled($channel_id,'connfilter')))
return true;
if(! $item)
return false;
if(! $abook)
return true;
if(! ($abook['abook_incl'] || $abook['abook_excl']))
return true;