Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-10-04 19:15:42 +03:00
1 parent b2549f867e
commit 3f177a77aa
29 files changed
+457 -196

No files matched your search

+5
View File
@@ -115,6 +115,11 @@ impl Cache {
self.touch(&mut index, key)
}
/// The cached server, channel, group or client icon, if available.
pub fn icon(&self, id: u32) -> Option<PathBuf> {
(id != 0).then(|| self.get(&icon_key(id))).flatten()
}
fn touch(&self, index: &mut Index, key: &str) -> Option<PathBuf> {
let path = self.dir.join(key);
let tick = index.entries.get(key)?.tick;
+3
View File
@@ -593,6 +593,9 @@ pub enum Event {
/// The server's details changed (also in [`Presence::server`]; voice).
ServerDetails {
session: SessionId,
/// The requested voice address that supplied these details. A queued
/// event may outlive a reconnect to another address in this session.
address: String,
details: Arc<ServerDetails>,
},
/// The server or channel groups changed (also in the presence; voice),
+34 -1
View File
@@ -148,6 +148,7 @@ struct Session {
state: SessionState,
generation: u64,
voice: Option<(u64, mpsc::UnboundedSender<VoiceCmd>)>,
voice_address: String,
voice_presence: Option<Presence>,
nickname: String,
gateway: Option<(u64, mpsc::UnboundedSender<GatewayCmd>)>,
@@ -239,6 +240,7 @@ impl Session {
state: SessionState::default(),
generation: 0,
voice: None,
voice_address: String::new(),
voice_presence: None,
nickname: String::new(),
gateway: None,
@@ -332,6 +334,8 @@ impl Session {
}
self.stop_streams("voice reconnecting");
let generation = self.next_generation();
self.voice_address = options.address.clone();
self.details = None;
self.nickname = options.nickname.clone();
self.stream_peer = options.stream_peer.clone();
if let Some(profiles) = &self.srtp_profiles {
@@ -1089,7 +1093,11 @@ impl Session {
if self.details.as_deref() != Some(&p.server) {
let details = Arc::new(p.server.clone());
self.details = Some(details.clone());
self.emit(Event::ServerDetails { session: self.id, details });
self.emit(Event::ServerDetails {
session: self.id,
address: self.voice_address.clone(),
details,
});
}
let sorted = |groups| -> Arc<Vec<GroupInfo>> {
Arc::new(Presence::sorted_groups(groups).into_iter().cloned().collect())
@@ -1867,6 +1875,31 @@ mod banner_tests {
(Session::new(1, events, frames, AudioSettings::default(), shared), receiver)
}
#[tokio::test]
async fn server_details_keep_source_address_and_repeat_after_reconnect() {
let (mut session, mut events) = session("details-address");
let mut presence = Presence::default();
presence.server.icon = 1234;
// Tasks are never polled in this test; the test runtime drops them
// without opening any network connections.
for address in ["a.test", "b.test", "b.test"] {
let mut options = crate::VoiceOptions::new(address, "test");
options.audio = false;
session.command(Command::ConnectVoice { session: 1, options: Box::new(options) });
session.report_details(&presence);
let mut reported = Vec::new();
while let Ok(event) = events.try_recv() {
if let Event::ServerDetails { address, details, .. } = event {
reported.push((address, details.icon));
}
}
assert_eq!(reported, vec![(address.to_owned(), 1234)]);
session.report_details(&presence);
assert!(events.try_recv().is_err());
}
session.stop_all();
}
#[tokio::test]
async fn failed_picture_retries_without_presence_update() {
let (mut session, mut events) = session("retry");