refactor: order self addresses by addition timestamp

This way the order does not change when
primary address is changed.
This commit is contained in:
link2xt
2026-03-12 14:04:22 +00:00
committed by l
parent a61a25f139
commit bdca3e5c09

View File

@@ -944,12 +944,18 @@ impl Context {
Ok(()) Ok(())
} }
/// Returns the primary self address followed by all secondary ones. /// Returns all self addresses, newest first.
pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>> { pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>> {
let primary_addrs = self.get_config(Config::ConfiguredAddr).await?.into_iter(); self.sql
let secondary_addrs = self.get_secondary_self_addrs().await?.into_iter(); .query_map_vec(
"SELECT addr FROM transports ORDER BY add_timestamp DESC",
Ok(primary_addrs.chain(secondary_addrs).collect()) (),
|row| {
let addr: String = row.get(0)?;
Ok(addr)
},
)
.await
} }
/// Returns all secondary self addresses. /// Returns all secondary self addresses.