Only extract information inside h-entry microformat

This commit is contained in:
Lewis Dale 2023-03-14 14:19:37 +00:00
parent 2735abde64
commit 811f63a207

View File

@ -104,7 +104,7 @@ class Endpoint {
MentionType::Like => "Liked this post", MentionType::Like => "Liked this post",
MentionType::Reply => $document->innerText(), MentionType::Reply => $document->innerText(),
MentionType::Repost => "Reposted this post", MentionType::Repost => "Reposted this post",
MentionType::Mention => $document->closest('a[href="' . $target . '"]')->innerText() MentionType::Mention => $document->innerText(),
}; };
} }
@ -114,9 +114,9 @@ class Endpoint {
if ($card) if ($card)
{ {
$name = $card->filter('.p-name')?->text(); $name = $card->filter('.p-name')?->text("");
$url = $card->filter('.u-url')?->text(); $url = $card->filter('.u-url')?->text("");
$photo = $card->filter('.u-photo')?->attr('src'); $photo = $card->filter('.u-photo')->count() ? $card->filter('.u-photo')->attr('src') : "";
return implode(", ", [$name, $url, $photo]); return implode(", ", [$name, $url, $photo]);
} }