Merge pull request #591 from MrPetovan/task/4867-guess-language-from-plaintext

Guess language from plaintext
This commit is contained in:
Michael Vogel 2018-04-23 00:26:30 +02:00 committed by GitHub
commit 9d33ccac28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 10 deletions

View file

@ -8,6 +8,7 @@
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -134,12 +135,15 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
return;
}
$naked_body = BBCode::toPlaintext($hook_data['item']['body'], false);
// Don't filter if body lenght is below minimum
$minlen = PConfig::get(local_user(), 'langfilter', 'minlength');
$minlen = PConfig::get(local_user(), 'langfilter', 'minlength', 32);
if (!$minlen) {
$minlen = 32;
}
if (strlen($hook_data['item']['body']) < $minlen) {
if (strlen($naked_body) < $minlen) {
return;
}