The transmitted language is now stored
This commit is contained in:
parent
2f1ec8e144
commit
dbda317c6d
|
@ -2002,13 +2002,23 @@ class Item
|
|||
return $item['language'];
|
||||
}
|
||||
|
||||
$transmitted = [];
|
||||
foreach ($item['transmitted-languages'] ?? [] as $language) {
|
||||
$transmitted[$language] = 0;
|
||||
}
|
||||
|
||||
if (!in_array($item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]) || empty($item['body'])) {
|
||||
return '';
|
||||
return empty($transmitted) ? '' : json_encode($transmitted);
|
||||
}
|
||||
|
||||
$languages = self::getLanguageArray($item['title'] . ' ' . ($item['content-warning'] ?? '') . ' ' . $item['body'], 3, $item['uri-id'], $item['author-id']);
|
||||
if (empty($languages)) {
|
||||
return '';
|
||||
return empty($transmitted) ? '' : json_encode($transmitted);
|
||||
}
|
||||
|
||||
if (!empty($transmitted)) {
|
||||
$languages = array_merge($transmitted, $languages);
|
||||
arsort($languages);
|
||||
}
|
||||
|
||||
return json_encode($languages);
|
||||
|
@ -2209,7 +2219,7 @@ class Item
|
|||
|
||||
// Glue it together to be able to make a hash from it
|
||||
if (!empty($parsed)) {
|
||||
$host_id = implode('/', $parsed);
|
||||
$host_id = implode('/', (array)$parsed);
|
||||
} else {
|
||||
$host_id = $uri;
|
||||
}
|
||||
|
@ -3435,7 +3445,7 @@ class Item
|
|||
unset($urlparts['fragment']);
|
||||
|
||||
try {
|
||||
$url = (string)Uri::fromParts($urlparts);
|
||||
$url = (string)Uri::fromParts((array)$urlparts);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
DI::logger()->notice('Invalid URL', ['$url' => $url, '$urlparts' => $urlparts]);
|
||||
/* See https://github.com/friendica/friendica/issues/12113
|
||||
|
|
|
@ -854,6 +854,8 @@ class Processor
|
|||
$item['language'] = self::processLanguages($activity['languages']);
|
||||
}
|
||||
|
||||
$item['transmitted-languages'] = $activity['transmitted-languages'];
|
||||
|
||||
if (!empty($activity['emojis'])) {
|
||||
$content = self::replaceEmojis($item['uri-id'], $content, $activity['emojis']);
|
||||
}
|
||||
|
@ -1727,7 +1729,7 @@ class Processor
|
|||
}
|
||||
}
|
||||
|
||||
$languages = self::getPostLanguages($activity);
|
||||
$languages = self::getPostLanguages($activity['as:object'] ?? '');
|
||||
|
||||
return Relay::isSolicitedPost($messageTags, $content, $authorid, $id, Protocol::ACTIVITYPUB, $activity['thread-completion'] ?? 0, $languages);
|
||||
}
|
||||
|
@ -1738,10 +1740,10 @@ class Processor
|
|||
* @param array $activity
|
||||
* @return array
|
||||
*/
|
||||
private static function getPostLanguages(array $activity): array
|
||||
public static function getPostLanguages(array $activity): array
|
||||
{
|
||||
$content = JsonLD::fetchElement($activity['as:object'], 'as:content') ?? '';
|
||||
$languages = JsonLD::fetchElementArray($activity['as:object'], 'as:content', '@language') ?? [];
|
||||
$content = JsonLD::fetchElement($activity, 'as:content') ?? '';
|
||||
$languages = JsonLD::fetchElementArray($activity, 'as:content', '@language') ?? [];
|
||||
if (empty($languages)) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -2005,6 +2005,7 @@ class Receiver
|
|||
$object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag') ?? []);
|
||||
$object_data['emojis'] = self::processEmojis(JsonLD::fetchElementArray($object, 'as:tag', null, '@type', 'toot:Emoji') ?? []);
|
||||
$object_data['languages'] = self::processLanguages(JsonLD::fetchElementArray($object, 'sc:inLanguage') ?? []);
|
||||
$object_data['transmitted-languages'] = Processor::getPostLanguages($object);
|
||||
$object_data['generator'] = JsonLD::fetchElement($object, 'as:generator', 'as:name', '@type', 'as:Application');
|
||||
$object_data['generator'] = JsonLD::fetchElement($object_data, 'generator', '@value');
|
||||
$object_data['alternate-url'] = JsonLD::fetchElement($object, 'as:url', '@id');
|
||||
|
|
Loading…
Reference in New Issue
Block a user