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/items.php | |
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/items.php')
-rw-r--r-- | include/items.php | 56 |
1 files changed, 45 insertions, 11 deletions
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); |