Merge branch 'issue/read-warnings' into 'main'

A few bug fixes in the /read endpoint.

See merge request edent/activitypub-single-php-file!4
main
Terence Eden 2024-03-04 08:59:18 +00:00
commit fd67482290
1 zmienionych plików z 5 dodań i 7 usunięć

Wyświetl plik

@ -576,7 +576,8 @@ HTML;
if ( isset( $message["published"] ) ) {
$published = $message["published"];
} else {
$published_hexstamp = end( explode( "/", explode( "-", $message_file)[0] ) ) ;
$segments = explode("/", explode("-", $inbox_file ?? "")[0]);
$published_hexstamp = end($segments);
$published_time = hexdec( $published_hexstamp );
$published = date( "c", $published_time );
@ -596,10 +597,8 @@ HTML;
foreach ( $messages_ordered as $published=>$message ) {
// Set up the common components
$object = $message["object"];
$object = $message["object"] ?? [];
// Get the message's ID.
// Set up the HTML representation
if ( isset( $message["object"]["id"] ) ) {
$id = $message["object"]["id"];
$publishedHTML = "<a href=\"{$id}\">{$published}</a>";
@ -625,10 +624,9 @@ HTML;
$actor = "https://example.com/anonymous";
}
// Assume that what comes after the final `/` in the URl is the name
$actorName = end( explode( "/", $actor ) );
$actorArray = explode( "/", $actor );
$actorName = end( $actorArray );
$actorServer = parse_url( $actor, PHP_URL_HOST );
$actorUsername = "@{$actorName}@{$actorServer}";
// Make i18n usernames readable and safe.
$actorName = htmlspecialchars( rawurldecode( $actorName ) );
$actorHTML = "<a href=\"$actor\">@{$actorName}</a>";