Merge remote-tracking branch 'upstream/2022.09-rc' into duplicates

This commit is contained in:
Michael 2022-09-21 03:46:25 +00:00
commit 36668dfdb1
15 changed files with 276 additions and 580 deletions

View file

@ -91,7 +91,7 @@ class Processor
* @param string $body
* @return string
*/
protected static function normalizeMentionLinks(string $body): string
public static function normalizeMentionLinks(string $body): string
{
return preg_replace('%\[url=([^\[\]]*)]([#@!])(.*?)\[/url]%ism', '$2[url=$1]$3[/url]', $body);
}

View file

@ -29,6 +29,7 @@ use Friendica\DI;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Search;
use Friendica\Model\Tag;
@ -76,6 +77,8 @@ class Relay
return false;
}
$body = ActivityPub\Processor::normalizeMentionLinks($body);
$systemTags = [];
$userTags = [];
$denyTags = [];
@ -125,6 +128,25 @@ class Relay
}
}
$languages = [];
foreach (Item::getLanguageArray($body, 10) as $language => $reliability) {
if ($reliability > 0) {
$languages[] = $language;
}
}
Logger::debug('Got languages', ['languages' => $languages, 'body' => $body]);
if (!empty($languages)) {
if (in_array($languages[0], $config->get('system', 'relay_deny_languages'))) {
Logger::info('Unwanted language found - rejected', ['language' => $languages[0], 'network' => $network, 'url' => $url]);
return false;
}
} elseif ($config->get('system', 'relay_deny_undetected_language')) {
Logger::info('Undetected language found - rejected', ['body' => $body, 'network' => $network, 'url' => $url]);
return false;
}
if ($scope == self::SCOPE_ALL) {
Logger::info('Server accept all posts - accepted', ['network' => $network, 'url' => $url]);
return true;