review: fix what the review of the gateway, avatar and banner changes found

- voelinctl observes with the new gateway list and checks avatar hashes
  only when they are MD5s (a myTeamSpeak avatar's hash is its link).
- Gateway discovery keeps to the most specific name that publishes a
  record; another server's gateway is no fallback. The admin guide says so.
- The observer's resync keeps the avatars clientlist does not tell
  (they come with the enter and update notifications).
- A server avatar given up on counts for that picture only: a new one is
  tried again, and one that arrives after all is shown again.
- updatemytsdata goes again after tsclientlib reconnects (the server
  forgets it), and once, not twice, when signing in.
- SVG is told by its prolog: a page with an svg in it (HTML, XHTML) is a
  page, refused and logged as one; the UI tells it the same way.
- Cursors (CUR) are no longer taken for pictures; MP4 and MOV are named
  videos, not AVIF.
- The UI decodes at most 128 MiB of pixels on its thread, drops the full
  picture before copying the small one, logs what it cannot decode, and
  remembers pictures it cannot show instead of decoding them on every
  refresh; a banner that reloads unchanged is not decoded again.
- The early refusal of a long error page is tested again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZBWxxMsxUzp4PSTKVzbZN
This commit is contained in:
Claude committed 2026-10-05 23:09:34 +00:00
1 parent 07038c58c3
commit 47f5e2d9aa
11 files changed
+415 -125

No files matched your search

+53 -1
View File
@@ -191,7 +191,8 @@ async fn session(
Some(n) => handle_notification(&n, presence, events),
None => {
// Resync and publish only what changed.
let fresh = load(&client).await?;
let listed = load(&client).await?;
let fresh = keep_unlisted(&presence.read().unwrap(), listed);
let deltas = presence.read().unwrap().diff(&fresh);
if !deltas.is_empty() {
debug!(changes = deltas.len(), "observer resync");
@@ -206,6 +207,24 @@ async fn session(
}
}
/// What `clientlist` does not tell (the avatars, which come with
/// `notifycliententerview` and `notifyclientupdated`), kept from what was
/// known of the same client: a resync must not take them away.
fn keep_unlisted(old: &Presence, mut fresh: Presence) -> Presence {
for (id, client) in &mut fresh.clients {
let Some(known) = old.clients.get(id).filter(|known| known.uid == client.uid) else {
continue;
};
if client.avatar.is_none() {
client.avatar.clone_from(&known.avatar);
}
if client.myts_avatar.is_none() {
client.myts_avatar.clone_from(&known.myts_avatar);
}
}
fresh
}
fn handle_notification(
n: &Notification,
presence: &RwLock<Presence>,
@@ -240,3 +259,36 @@ fn handle_notification(
let _ = events.send(ObserverEvent::Delta(d));
}
}
#[cfg(test)]
mod resync_tests {
use super::*;
use voelin_model::ClientInfo;
#[test]
fn a_resync_keeps_the_avatars_the_list_does_not_tell() {
let client = |uid: &str, myts: Option<&str>| ClientInfo {
id: 5,
uid: Some(uid.into()),
nickname: "a".into(),
avatar: myts.map(|_| "0123456789abcdef0123456789abcdef".into()),
myts_avatar: myts.map(Into::into),
..Default::default()
};
let mut old = Presence::default();
old.clients.insert(5, client("u=", Some("https://a.example.test/on.png")));
let mut listed = Presence::default();
listed.clients.insert(5, client("u=", None));
let fresh = keep_unlisted(&old, listed.clone());
assert_eq!(fresh.clients[&5], old.clients[&5]);
assert!(old.diff(&fresh).is_empty());
// Another client in the same slot starts without them.
let mut other = Presence::default();
other.clients.insert(5, client("v=", None));
let fresh = keep_unlisted(&old, other);
assert_eq!(
(fresh.clients[&5].avatar.clone(), fresh.clients[&5].myts_avatar.clone()),
(None, None)
);
}
}