diff options
author | Mario <mario@mariovavti.com> | 2022-03-01 10:14:05 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-03-01 10:14:05 +0000 |
commit | 01b9f2dfcf3b23dcbf1dff06e7e42397840594a9 (patch) | |
tree | dfc971f5c51477cb7705c0e0e7a7c3945c7ceb85 /include | |
parent | 0cc6f66a26181319738db8150074f62b3684f97e (diff) | |
download | volse-hubzilla-01b9f2dfcf3b23dcbf1dff06e7e42397840594a9.tar.gz volse-hubzilla-01b9f2dfcf3b23dcbf1dff06e7e42397840594a9.tar.bz2 volse-hubzilla-01b9f2dfcf3b23dcbf1dff06e7e42397840594a9.zip |
enhanced content filters
Diffstat (limited to 'include')
-rw-r--r-- | include/feedutils.php | 10 | ||||
-rw-r--r-- | include/items.php | 56 |
2 files changed, 51 insertions, 15 deletions
diff --git a/include/feedutils.php b/include/feedutils.php index b21495d72..fbd97b598 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1060,6 +1060,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { return; } + + $sys_expire = intval(get_config('system', 'default_expire_days')); $chn_expire = intval($importer['channel_expire_days']); @@ -1353,7 +1355,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']; @@ -1509,7 +1511,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); @@ -1764,8 +1766,8 @@ function handle_feed($uid, $abook_id, $url) { //logger('data:' . print_r($z, true), LOGGER_DATA); if($z['success']) { - consume_feed($z['body'], $channel, $x[0], 1); - consume_feed($z['body'], $channel, $x[0], 2); + consume_feed($z['body'], $channel, $x, 1); + consume_feed($z['body'], $channel, $x, 2); return true; } diff --git a/include/items.php b/include/items.php index 0b33d876d..10a5a3385 100644 --- a/include/items.php +++ b/include/items.php @@ -10,6 +10,7 @@ use Zotlabs\Lib\MarkdownSoap; use Zotlabs\Lib\MessageFilter; use Zotlabs\Lib\ThreadListener; use Zotlabs\Lib\IConfig; +use Zotlabs\Lib\PConfig; use Zotlabs\Lib\Activity; use Zotlabs\Lib\Libsync; use Zotlabs\Lib\Libzot; @@ -2218,9 +2219,9 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { $arr['deny_gid'] = ((array_key_exists('deny_gid',$arr)) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']); $arr['item_private'] = ((array_key_exists('item_private',$arr)) ? intval($arr['item_private']) : $orig[0]['item_private']); - $arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : ''); - $arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : ''); - $arr['html'] = ((array_key_exists('html',$arr) && strlen($arr['html'])) ? trim($arr['html']) : ''); + $arr['title'] = ((array_key_exists('title',$arr) && $arr['title']) ? trim($arr['title']) : ''); + $arr['body'] = ((array_key_exists('body',$arr) && $arr['body']) ? trim($arr['body']) : ''); + $arr['html'] = ((array_key_exists('html',$arr) && $arr['html']) ? trim($arr['html']) : ''); $arr['attach'] = ((array_key_exists('attach',$arr)) ? notags(trim($arr['attach'])) : $orig[0]['attach']); $arr['app'] = ((array_key_exists('app',$arr)) ? notags(trim($arr['app'])) : $orig[0]['app']); @@ -3495,24 +3496,57 @@ function check_item_source($uid, $item) { return false; } -function post_is_importable($item,$abook) { - if(! $abook) - return true; +// Checks an incoming item against the per-channel and per-connection content filter. +// This implements the backend of the 'Content Filter' system app - if(($abook['abook_channel']) && (! feature_enabled($abook['abook_channel'],'connfilter'))) - return true; +function post_is_importable($channel_id, $item, $abook) { - if(! $item) + if (! $item) { return false; + } + + $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(!feature_enabled($channel_id, 'connfilter')) { + return true; + } - if(! ($abook['abook_incl'] || $abook['abook_excl'])) + if (! $abook) { return true; + } - return MessageFilter::evaluate($item,$abook['abook_incl'],$abook['abook_excl']); + foreach ($abook as $ab) { + // check eligibility + if (intval($ab['abook_self'])) { + continue; + } + if (! ($ab['abook_incl'] || $ab['abook_excl'])) { + continue; + } + $evaluator = MessageFilter::evaluate($item, $ab['abook_incl'], $ab['abook_excl']); + // A negative assessment for any individual connections + // is an instant fail + if (! $evaluator) { + logger('MessageFilter: connection blocked content', LOGGER_DEBUG, LOG_INFO); + return false; + } + } + + return true; } + function fix_private_photos($s, $uid, $item = null, $cid = 0) { logger('fix_private_photos', LOGGER_DEBUG); |