💄 de-dupe unregistered servers list
parent
810a34463c
commit
62248aca53
|
@ -22,6 +22,7 @@
|
|||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashSet,
|
||||
convert::Infallible,
|
||||
net::SocketAddr,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -358,20 +359,33 @@ async fn handle_unregistered_servers_internal (state: &Arc <Relay>)
|
|||
let now = Utc::now ();
|
||||
|
||||
let server_list = state.unregistered_servers.to_vec ().await;
|
||||
let mut seen_tripcodes = HashSet::new ();
|
||||
|
||||
let unregistered_servers = server_list.into_iter ()
|
||||
.map (|x| {
|
||||
.rev ()
|
||||
.filter_map (|x| {
|
||||
let last_seen = match pretty_print_last_seen (now, x.seen) {
|
||||
Negative => "Error (negative time)".into (),
|
||||
Connected => "Recently".into (),
|
||||
Description (s) => s,
|
||||
};
|
||||
|
||||
UnregisteredServer {
|
||||
name: x.name,
|
||||
tripcode: base64::encode (x.tripcode.as_bytes ()),
|
||||
last_seen,
|
||||
let t = (x.name, x.tripcode);
|
||||
|
||||
if seen_tripcodes.contains (&t) {
|
||||
return None;
|
||||
}
|
||||
seen_tripcodes.insert (t.clone ());
|
||||
|
||||
let (name, tripcode) = t;
|
||||
|
||||
let tripcode = base64::encode (tripcode.as_bytes ());
|
||||
|
||||
Some (UnregisteredServer {
|
||||
name,
|
||||
tripcode,
|
||||
last_seen,
|
||||
})
|
||||
}).collect ();
|
||||
|
||||
UnregisteredServerListPage {
|
||||
|
|
Loading…
Reference in New Issue