mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
feat: show real TeamSpeak avatars
The connector now reports client_flag_avatar (the avatar's MD5) per client. The browser derives /avatar_<uid> from the UID and fetches it through the existing channel-0 file cache used for group icons, again whenever the hash changes. Only the own channel and the selected client are fetched, so a big server does not push every avatar through the gateway; avatars are capped at 512 KiB like icons. They replace the initials tile in the tree (Nova/Pulse), the speaking-now bar, and appear in the client info panel. Also fixes the Nova connect dialog staying open over an auto-connect: its "forced open while disconnected" effect ran after the auto-connect had closed it, and nothing closed it again once connected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
7b3cb5ef09
commit
4b245d69d3
4 files changed
+124
-17
No files matched your search
+12
-1
@@ -38,6 +38,9 @@ const FRAME_SAMPLES: usize = 960;
|
||||
/// Upper bound for a file download relayed to the browser (see its use).
|
||||
const MAX_DOWNLOAD_BYTES: u64 = 25 << 20;
|
||||
const MAX_ICON_BYTES: u64 = 512 << 10;
|
||||
/// Avatars are fetched for everyone in the user's channel without asking;
|
||||
/// TS3 servers default to a 300 KiB avatar size limit.
|
||||
const MAX_AVATAR_BYTES: u64 = 512 << 10;
|
||||
const OUT_CHANNELS: usize = 2;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -118,6 +121,9 @@ struct ClientInfo {
|
||||
/// sends no stream command in that case, so the id has to be fetched with
|
||||
/// `requeststreaminfo`. Always `false` on servers that don't report it.
|
||||
is_streaming: bool,
|
||||
/// `client_flag_avatar`: MD5 of the client's avatar, empty without one. The
|
||||
/// file itself is `/avatar_<uid>` in channel 0, fetched by the browser.
|
||||
avatar_hash: String,
|
||||
}
|
||||
|
||||
/// Payload for the "streamsetup " stdin command - the `setupstream` args, which
|
||||
@@ -669,6 +675,7 @@ fn snapshot(con: &data::Connection) -> Event {
|
||||
has_talk_power,
|
||||
is_query: matches!(c.client_type, ClientType::Query { .. }),
|
||||
is_streaming: c.is_streaming.unwrap_or(false),
|
||||
avatar_hash: c.avatar_hash.clone(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -2955,7 +2962,11 @@ async fn run(args: Args) -> Result<()> {
|
||||
let announced_size = result.size;
|
||||
// Group/server icons are fetched automatically, without the user
|
||||
// asking, so they get a far smaller budget than explicit downloads.
|
||||
let limit = if cid == 0 && path.starts_with("/icon_") { MAX_ICON_BYTES } else { MAX_DOWNLOAD_BYTES };
|
||||
let limit = match path.as_str() {
|
||||
p if cid == 0 && p.starts_with("/icon_") => MAX_ICON_BYTES,
|
||||
p if cid == 0 && p.starts_with("/avatar_") => MAX_AVATAR_BYTES,
|
||||
_ => MAX_DOWNLOAD_BYTES,
|
||||
};
|
||||
tokio::spawn(async move {
|
||||
if announced_size > limit {
|
||||
emit(&Event::Error {
|
||||
|
||||
Reference in new issue
Block a user