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);
// 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;
}
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
$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']);
}
}
}
- $languages = self::getPostLanguages($activity);
+ $languages = self::getPostLanguages($activity['as:object'] ?? '');
return Relay::isSolicitedPost($messageTags, $content, $authorid, $id, Protocol::ACTIVITYPUB, $activity['thread-completion'] ?? 0, $languages);
}
* @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 [];
}
$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');