A few bug fixes in the /read endpoint.

merge-requests/5/head
Jeff Sikes 2024-03-04 08:59:18 +00:00 zatwierdzone przez Terence Eden
rodzic 5fdfd84e6f
commit b0b8b61a0a
1 zmienionych plików z 5 dodań i 7 usunięć

Wyświetl plik

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