forked from friendica/friendica-addons
Issue 15048: Support addon filters via API
This commit is contained in:
parent
ea41e2f1b6
commit
b39ab36cee
3 changed files with 16 additions and 14 deletions
|
@ -99,8 +99,8 @@ function langfilter_addon_settings_post(array &$b)
|
|||
|
||||
function langfilter_prepare_body_content_filter(&$hook_data)
|
||||
{
|
||||
$logged_user = DI::userSession()->getLocalUserId();
|
||||
if (!$logged_user) {
|
||||
$uid = $hook_data['uid'] ?: DI::userSession()->getLocalUserId();
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
}
|
||||
|
||||
// Don't filter if language filter is disabled
|
||||
if (!DI::pConfig()->get($logged_user, 'langfilter', 'enable',
|
||||
!DI::pConfig()->get($logged_user, 'langfilter', 'disable'))
|
||||
if (!DI::pConfig()->get($uid, 'langfilter', 'enable',
|
||||
!DI::pConfig()->get($uid, 'langfilter', 'disable'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
$naked_body = preg_replace('#\s+#', ' ', trim($naked_body));
|
||||
|
||||
// Don't filter if body lenght is below minimum
|
||||
$minlen = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minlength', 32);
|
||||
$minlen = DI::pConfig()->get($uid, 'langfilter', 'minlength', 32);
|
||||
if (!$minlen) {
|
||||
$minlen = 32;
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
return;
|
||||
}
|
||||
|
||||
$read_languages_string = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'languages');
|
||||
$minconfidence = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minconfidence');
|
||||
$read_languages_string = DI::pConfig()->get($uid, 'langfilter', 'languages');
|
||||
$minconfidence = DI::pConfig()->get($uid, 'langfilter', 'minconfidence');
|
||||
|
||||
// Don't filter if no spoken languages are configured
|
||||
if (!$read_languages_string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue