Make message processing quicker. Remove Undo from display
rodzic
fad6ad7c20
commit
6498267448
12
index.php
12
index.php
|
@ -509,8 +509,10 @@ echo <<< HTML
|
||||||
HTML;
|
HTML;
|
||||||
// Get all the files in the directory
|
// Get all the files in the directory
|
||||||
$message_files = array_reverse( glob( $directories[$directory] . "/*.json") );
|
$message_files = array_reverse( glob( $directories[$directory] . "/*.json") );
|
||||||
// Keep the most recent 200
|
// There are lots of messages. The UI will only show 200.
|
||||||
$message_files = array_slice( $message_files, 0, 200 );
|
// However, there will be lots of duplicates, updates, etc.
|
||||||
|
// This looks through the most recent 1,000
|
||||||
|
$message_files = array_slice( $message_files, 0, 1000 );
|
||||||
|
|
||||||
// Loop through the messages:
|
// Loop through the messages:
|
||||||
// Remove any which have been updated.
|
// Remove any which have been updated.
|
||||||
|
@ -521,6 +523,10 @@ HTML;
|
||||||
// Get the contents of the JSON
|
// Get the contents of the JSON
|
||||||
$message = json_decode( file_get_contents( $message_file ), true );
|
$message = json_decode( file_get_contents( $message_file ), true );
|
||||||
|
|
||||||
|
// Ignore any messages which aren't for display
|
||||||
|
$type = $message["type"];
|
||||||
|
if ( "Undo" == $type ) { continue; }
|
||||||
|
|
||||||
// Get the ID
|
// Get the ID
|
||||||
if ( isset( $message["object"]["id"] ) ) {
|
if ( isset( $message["object"]["id"] ) ) {
|
||||||
$id = $message["object"]["id"];
|
$id = $message["object"]["id"];
|
||||||
|
@ -554,6 +560,8 @@ HTML;
|
||||||
|
|
||||||
// Sort with newest on top
|
// Sort with newest on top
|
||||||
krsort( $messages_ordered );
|
krsort( $messages_ordered );
|
||||||
|
// Only keep the most recent 200
|
||||||
|
$messages_ordered = array_slice( $messages_ordered, 0, 200 );
|
||||||
|
|
||||||
// HTML is *probably* sanitised by the sender. But let's not risk it, eh?
|
// HTML is *probably* sanitised by the sender. But let's not risk it, eh?
|
||||||
// Using the allow-list from https://docs.joinmastodon.org/spec/activitypub/#sanitization
|
// Using the allow-list from https://docs.joinmastodon.org/spec/activitypub/#sanitization
|
||||||
|
|
Ładowanie…
Reference in New Issue