The product is Voelin (app id io.github.faumaray.Voelin), everywhere: - crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary tsc-desktop -> voelin, the development CLI tsctl -> voelinctl; - the Android app: applicationId, Kotlin package io.github.faumaray.voelin, VoelinApp, libvoelin_android.so (JNI class names follow); - TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* -> voelin.*, signing secrets VOELIN_SIGNING_*; - the data/config/cache/state folder tsc -> voelin, the keyring service, thread names, the dev compose project; - desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs. The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env vars, the tsgw.v1+json protocol, the tsgw image. The window title and the About page show "Voelin <version>" from voelin_platform::APP_NAME. Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs, Flatpak). voelinctl is a development tool and in no package. tsgw is for servers and now its own Linux package, tsgw_<v>_amd64.deb and tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit (packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and dependencies of its own (no GUI libraries). docs/gateway-admin.md has an Install section. Fixes: - package-windows: makensis on Windows found no file through "D:/a/..." paths; pass Windows paths (cygpath -w). - StartupWMClass is the app id, which the app sets as its X11 WM_CLASS (it was the binary name, so desktops could not match the window). - Gradle wrapper download timeout 10 s -> 60 s (slow proxies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
82 lines
2.2 KiB
Rust
82 lines
2.2 KiB
Rust
//! Chat messages, from any source.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::presence::{ChannelId, ClientId};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[serde(tag = "kind", content = "id", rename_all = "snake_case")]
|
|
pub enum ChatTarget {
|
|
/// Everyone on the server.
|
|
Server,
|
|
Channel(ChannelId),
|
|
/// Private chat, by the other side's unique id when known.
|
|
Private(String),
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub struct ChatMessage {
|
|
pub target: ChatTarget,
|
|
pub author_name: String,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub author_uid: Option<String>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub author_id: Option<ClientId>,
|
|
pub text: String,
|
|
/// Unix time in milliseconds.
|
|
pub ts_ms: i64,
|
|
/// Carried by a gateway or query relay rather than our own connection.
|
|
#[serde(default)]
|
|
pub via_relay: bool,
|
|
}
|
|
|
|
/// Format of messages a relay posts on behalf of a user.
|
|
pub fn relay_text(format: &str, nick: &str, text: &str) -> String {
|
|
format.replace("{nick}", nick).replace("{text}", text)
|
|
}
|
|
|
|
/// Split text so each part fits TeamSpeak's message limit (1024 bytes of
|
|
/// text), breaking at character boundaries.
|
|
pub fn split_message(text: &str, max_bytes: usize) -> Vec<String> {
|
|
let mut parts = Vec::new();
|
|
let mut current = String::new();
|
|
for c in text.chars() {
|
|
if current.len() + c.len_utf8() > max_bytes {
|
|
parts.push(std::mem::take(&mut current));
|
|
}
|
|
current.push(c);
|
|
}
|
|
if !current.is_empty() || parts.is_empty() {
|
|
parts.push(current);
|
|
}
|
|
parts
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn relay_format() {
|
|
assert_eq!(relay_text("[{nick}] {text}", "Alice", "hi"), "[Alice] hi");
|
|
}
|
|
|
|
#[test]
|
|
fn splits_on_char_boundaries() {
|
|
assert_eq!(split_message("abcdef", 4), vec!["abcd", "ef"]);
|
|
assert_eq!(split_message("", 4), vec![""]);
|
|
let parts = split_message("ääää", 3);
|
|
assert!(parts.iter().all(|p| p.len() <= 3));
|
|
assert_eq!(parts.concat(), "ääää");
|
|
}
|
|
|
|
#[test]
|
|
fn target_json() {
|
|
assert_eq!(
|
|
serde_json::to_string(&ChatTarget::Channel(5)).unwrap(),
|
|
r#"{"kind":"channel","id":5}"#
|
|
);
|
|
assert_eq!(serde_json::to_string(&ChatTarget::Server).unwrap(), r#"{"kind":"server"}"#);
|
|
}
|
|
}
|