Simplified language check
This commit is contained in:
parent
6e830f7774
commit
da02df20c3
|
@ -644,6 +644,10 @@ class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!DI::config()->get('system', 'relay_deny_undetected_language')) {
|
||||||
|
$languages['un'] = 'un';
|
||||||
|
}
|
||||||
|
|
||||||
ksort($languages);
|
ksort($languages);
|
||||||
$languages = array_keys($languages);
|
$languages = array_keys($languages);
|
||||||
DI::cache()->set($cachekey, $languages);
|
DI::cache()->set($cachekey, $languages);
|
||||||
|
|
|
@ -188,34 +188,31 @@ class Relay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($languages) && empty($detected) && (empty($body) || Smilies::isEmojiPost($body))) {
|
if (empty($detected)) {
|
||||||
|
$detected = ['un'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($body) || Smilies::isEmojiPost($body)) {
|
||||||
Logger::debug('Empty body or only emojis', ['body' => $body]);
|
Logger::debug('Empty body or only emojis', ['body' => $body]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($languages) || !empty($detected)) {
|
$user_languages = User::getLanguages();
|
||||||
$user_languages = User::getLanguages();
|
|
||||||
|
|
||||||
foreach ($detected as $language) {
|
foreach ($detected as $language) {
|
||||||
if (in_array($language, $user_languages)) {
|
if (in_array($language, $user_languages)) {
|
||||||
Logger::debug('Wanted language found in detected languages', ['language' => $language, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
Logger::debug('Wanted language found in detected languages', ['language' => $language, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach ($languages as $language) {
|
|
||||||
if (in_array($language, $user_languages)) {
|
|
||||||
Logger::debug('Wanted language found in defined languages', ['language' => $language, 'languages' => $languages, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Logger::debug('No wanted language found', ['languages' => $languages, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
|
||||||
return false;
|
|
||||||
} elseif (DI::config()->get('system', 'relay_deny_undetected_language')) {
|
|
||||||
Logger::info('Undetected language found', ['body' => $body]);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
foreach ($languages as $language) {
|
||||||
return true;
|
if (in_array($language, $user_languages)) {
|
||||||
|
Logger::debug('Wanted language found in defined languages', ['language' => $language, 'languages' => $languages, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger::debug('No wanted language found', ['languages' => $languages, 'detected' => $detected, 'userlang' => $user_languages, 'body' => $body]);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user