Use UUID for saving inbox messagse. Makes them less likely to clash.

merge-requests/5/head
Terence Eden 2024-03-01 22:54:22 +00:00
rodzic 3e41d98c35
commit 69b0df6e87
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -269,8 +269,8 @@
default => false, default => false,
} ) { } ) {
// Save the message in `/data/inbox/` // Save the message in `/data/inbox/`
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED ); $uuid = uuid();
$inbox_filename = $timestamp . "." . urlencode( $inbox_type ) . ".json"; $inbox_filename = $uuid . "." . urlencode( $inbox_type ) . ".json";
file_put_contents( $directories["inbox"] . "/{$inbox_filename}", json_encode( $inbox_message ) ); file_put_contents( $directories["inbox"] . "/{$inbox_filename}", json_encode( $inbox_message ) );
} }
@ -1125,7 +1125,10 @@ HTML;
if ( isset( $inbox_message["published"] ) ) { if ( isset( $inbox_message["published"] ) ) {
$published = $inbox_message["published"]; $published = $inbox_message["published"];
} else { } else {
$published = end( explode( "/", explode( ".", $inbox_file)[0] ) ) ; $published_hexstamp = end( explode( "/", explode( "-", $inbox_file)[0] ) ) ;
$published_time = hexdec( $published_hexstamp );
$published = date( "c", $published_time );
} }
// Place in an array where the key is the timestamp // Place in an array where the key is the timestamp
$inbox_ordered[$published] = $inbox_message; $inbox_ordered[$published] = $inbox_message;