From b0b8b61a0a813ea6e6767972f833ed52997389b0 Mon Sep 17 00:00:00 2001 From: Jeff Sikes <20144588-jeffsikes@users.noreply.gitlab.com> Date: Mon, 4 Mar 2024 08:59:18 +0000 Subject: [PATCH] A few bug fixes in the /read endpoint. --- index.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 4632878..d708292 100644 --- a/index.php +++ b/index.php @@ -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 = "{$published}"; @@ -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 = "@{$actorName}";