$actor = JsonLD::fetchElement($ldactivity, 'as:actor', '@id');
$apcontact = APContact::getByURL($actor);
- if (!empty($apcontact) && ($apcontact['type'] == 'Application') && ($apcontact['nick'] == 'relay')) {
+ if (empty($apcontact)) {
+ Logger::notice('Unable to retrieve AP contact for actor', ['actor' => $actor]);
+ } elseif ($apcontact['type'] == 'Application' && $apcontact['nick'] == 'relay') {
self::processRelayPost($ldactivity, $actor);
return;
+ } else {
+ APContact::unmarkForArchival($apcontact);
}
$http_signer = HTTPSignature::getSigner($body, $header);
$profile = APContact::getByURL($object_id);
if (!empty($profile['type'])) {
+ APContact::unmarkForArchival($profile);
return 'as:' . $profile['type'];
}
$filetype = strtolower(substr($mediatype, 0, strpos($mediatype, '/')));
if ($filetype == 'audio') {
- $attachments[$filetype] = ['type' => $mediatype, 'url' => $href];
+ $attachments[$filetype] = ['type' => $mediatype, 'url' => $href, 'height' => null, 'size' => null];
} elseif ($filetype == 'video') {
$height = (int)JsonLD::fetchElement($url, 'as:height', '@value');
+ $size = (int)JsonLD::fetchElement($url, 'pt:size', '@value');
- // We save bandwidth by using a moderate height
+ // We save bandwidth by using a moderate height (alt least 480 pixel height)
// Peertube normally uses these heights: 240, 360, 480, 720, 1080
if (!empty($attachments[$filetype]['height']) &&
- (($height > 480) || $height < $attachments[$filetype]['height'])) {
+ ($height > $attachments[$filetype]['height']) && ($attachments[$filetype]['height'] >= 480)) {
+ continue;
+ }
+
+ $attachments[$filetype] = ['type' => $mediatype, 'url' => $href, 'height' => $height, 'size' => $size];
+ } elseif (in_array($mediatype, ['application/x-bittorrent', 'application/x-bittorrent;x-scheme-handler/magnet'])) {
+ $height = (int)JsonLD::fetchElement($url, 'as:height', '@value');
+
+ // For Torrent links we always store the highest resolution
+ if (!empty($attachments[$mediatype]['height']) && ($height < $attachments[$mediatype]['height'])) {
continue;
}
- $attachments[$filetype] = ['type' => $mediatype, 'url' => $href, 'height' => $height];
+ $attachments[$mediatype] = ['type' => $mediatype, 'url' => $href, 'height' => $height, 'size' => null];
}
}
foreach ($attachments as $type => $attachment) {
$object_data['attachments'][] = ['type' => $type,
'mediaType' => $attachment['type'],
+ 'height' => $attachment['height'],
+ 'size' => $attachment['size'],
'name' => '',
'url' => $attachment['url']];
}
$object_data['longitude'] = JsonLD::fetchElement($object_data, 'longitude', '@value');
$object_data['attachments'] = self::processAttachments(JsonLD::fetchElementArray($object, 'as:attachment') ?? []);
$object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag') ?? []);
- $object_data['emojis'] = self::processEmojis(JsonLD::fetchElementArray($object, 'as:tag', 'toot:Emoji') ?? []);
+ $object_data['emojis'] = self::processEmojis(JsonLD::fetchElementArray($object, 'as:tag', null, '@type', 'toot:Emoji') ?? []);
$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');