From 721496f9220fa59059f90d16d3b3fb19337b2f16 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 May 2018 17:11:03 -0700 Subject: hubzilla issue #1169 --- include/feedutils.php | 12 ++++++++++ include/items.php | 63 +-------------------------------------------------- include/zot.php | 5 ++++ 3 files changed, 18 insertions(+), 62 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 023caaad6..afbe4229e 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1332,6 +1332,12 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // immediate parent wasn't found. Turn into a top-level post if permissions allow // but save the thread_parent in case we need to refer to it later. + if($importer['channel_system']) { + if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) { + continue; + } + } + if(! post_is_importable($datarray, $contact)) continue; @@ -1482,6 +1488,12 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $author['owner_avatar'] = $contact['thumb']; } + if($importer['channel_system']) { + if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) { + continue; + } + } + if(! post_is_importable($datarray, $contact)) continue; diff --git a/include/items.php b/include/items.php index d7cf9c558..1c0ef418a 100755 --- a/include/items.php +++ b/include/items.php @@ -3129,69 +3129,8 @@ function post_is_importable($item,$abook) { if(! ($abook['abook_incl'] || $abook['abook_excl'])) return true; - require_once('include/html2plain.php'); - - unobscure($item); - - $text = prepare_text($item['body'],$item['mimetype']); - $text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text); - - - $lang = null; - - if((strpos($abook['abook_incl'],'lang=') !== false) || (strpos($abook['abook_excl'],'lang=') !== false)) { - $lang = detect_language($text); - } - $tags = ((count($item['term'])) ? $item['term'] : false); - - // exclude always has priority - - $exclude = (($abook['abook_excl']) ? explode("\n",$abook['abook_excl']) : null); - - if($exclude) { - foreach($exclude as $word) { - $word = trim($word); - if(! $word) - continue; - if(substr($word,0,1) === '#' && $tags) { - foreach($tags as $t) - if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) - return false; - } - elseif((strpos($word,'/') === 0) && preg_match($word,$text)) - return false; - elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) - return false; - elseif(stristr($text,$word) !== false) - return false; - } - } - - $include = (($abook['abook_incl']) ? explode("\n",$abook['abook_incl']) : null); + return \Zotlabs\Lib\MessageFilter::evaluate($item,$abook['abook_incl'],$abook['abook_excl']); - if($include) { - foreach($include as $word) { - $word = trim($word); - if(! $word) - continue; - if(substr($word,0,1) === '#' && $tags) { - foreach($tags as $t) - if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) - return true; - } - elseif((strpos($word,'/') === 0) && preg_match($word,$text)) - return true; - elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) - return true; - elseif(stristr($text,$word) !== false) - return true; - } - } - else { - return true; - } - - return false; } diff --git a/include/zot.php b/include/zot.php index 0343f4464..14c9f6ae5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1787,6 +1787,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $local_public = false; continue; } + if(! \Zotlabs\Lib\MessageFilter::evaluate($arr,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) { + $local_public = false; + continue; + } } $tag_delivery = tgroup_check($channel['channel_id'],$arr); @@ -1923,6 +1927,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ continue; } + $r = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval($channel['channel_id']) -- cgit v1.2.3