lemmy attached pages (again)

This commit is contained in:
Mike Macgirvin 2023-11-07 07:41:22 +11:00
parent 19d42dbb9f
commit 854ee1049c

View file

@ -3519,35 +3519,48 @@ class Activity
} else {
$ptr = [$act->obj['url']];
}
foreach ($ptr as $vurl) {
if (! is_array($vurl)) {
continue;
}
if (array_key_exists('mediaType', $vurl) && $vurl['mediaType'] === 'text/html') {
$purl = $vurl['href'];
break;
} elseif (array_key_exists('mimeType', $vurl) && $vurl['mimeType'] === 'text/html') {
$purl = $vurl['href'];
break;
} elseif ($item['mimetype'] === 'text/html') {
// lemmy makes everything difficult to parse; this time by putting the mediaType on the object but not the link
// we can target this specifically because there's a mediaType set on the object but no content could be found.
$purl = $vurl['href'];
break;
}
}
} elseif (is_string($act->obj['url'])) {
$purl = $act->obj['url'];
}
if ($purl) {
$li = Url::get(z_root() . '/linkinfo?binurl=' . bin2hex($purl));
if ($li['success'] && $li['body']) {
$item['body'] .= "\n" . $li['body'];
}
elseif (array_key_exists('attachment', $act->obj)) {
if (is_array($act->obj['attachment'])) {
if (array_key_exists(0, $act->obj['attachment'])) {
$ptr = $act->obj['attachement'];
} else {
$item['body'] .= "\n\n" . $purl;
$ptr = [$act->obj['attachement']];
}
}
}
if ($ptr) {
foreach ($ptr as $vurl) {
if (! is_array($vurl)) {
continue;
}
if (array_key_exists('mediaType', $vurl) && $vurl['mediaType'] === 'text/html') {
$purl = $vurl['href'];
break;
} elseif (array_key_exists('mimeType', $vurl) && $vurl['mimeType'] === 'text/html') {
$purl = $vurl['href'];
break;
} elseif ($item['mimetype'] === 'text/html') {
// lemmy makes everything difficult to parse; this time by putting the mediaType on the object but not the link
// we can target this specifically because there's a mediaType set on the object but no content could be found.
$purl = $vurl['href'];
break;
}
}
} elseif (is_string($act->obj['url'])) {
$purl = $act->obj['url'];
} elseif (is_string($act->obj['attachment'])) {
$purl = $act->obj['attachment'];
}
if ($purl) {
$li = Url::get(z_root() . '/linkinfo?binurl=' . bin2hex($purl));
if ($li['success'] && $li['body']) {
$item['body'] .= "\n" . $li['body'];
} else {
$item['body'] .= "\n\n" . $purl;
}
}
}
}