mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Add Bannliste and Beschwerdeliste management dialogs
Implements #91 (ban list) and #92 (complaint list), reusing the StreamItem::MessageEvent handling infrastructure added for #94. Connector: - New raw commands: banlist, bandel, bandelall, complainlist, complaindel, complaindelall (no typed builders exist for these). - New pending_ban_list/pending_complain_list flags + MessageEvent match arms parsing InMessage::BanList/ComplainList replies into BanListEntry/ComplainListEntry structs, emitted as banList/ complainList events. - Unlike serverlog/serverconninfo, the test server actually replies with an error return code for these (surfaced as a "permission error" Server-tab log line) rather than staying silent - the connector already handles that path via the existing pending message result matching. Gateway: getBanList/deleteBan/deleteAllBans/getComplainList/ deleteComplaint/deleteAllComplaintsFor methods and message cases, plus camelCase remapping for the two new event types. Frontend: BanListDialog and ComplainListDialog components (table view, per-row delete + delete-all for bans, optimistic local removal on delete), wired into the Extras menu (previously disabled placeholders), with the same 6s timeout-to-"unavailable" fallback pattern used by the other async-reply dialogs. Demo mode gets fake ban/complaint entries. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4318ce359f
commit
bd0122812d
7 files changed
+678
-13
No files matched your search
@@ -238,6 +238,38 @@ enum Event {
|
|||||||
/// client-join/channel-edit/etc. feed for the Server tab).
|
/// client-join/channel-edit/etc. feed for the Server tab).
|
||||||
#[serde(rename = "serverProtocolLog")]
|
#[serde(rename = "serverProtocolLog")]
|
||||||
ServerProtocolLog { lines: Vec<String> },
|
ServerProtocolLog { lines: Vec<String> },
|
||||||
|
/// Reply to a "banlist" request.
|
||||||
|
#[serde(rename = "banList")]
|
||||||
|
BanList { entries: Vec<BanListEntry> },
|
||||||
|
/// Reply to a "complainlist" request.
|
||||||
|
#[serde(rename = "complainList")]
|
||||||
|
ComplainList { entries: Vec<ComplainListEntry> },
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
struct BanListEntry {
|
||||||
|
ban_id: u32,
|
||||||
|
ip: String,
|
||||||
|
name: String,
|
||||||
|
uid: String,
|
||||||
|
last_nickname: String,
|
||||||
|
created: String,
|
||||||
|
duration_secs: i64,
|
||||||
|
invoker_name: String,
|
||||||
|
reason: String,
|
||||||
|
enforcements: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
struct ComplainListEntry {
|
||||||
|
target_client_db_id: u64,
|
||||||
|
target_name: String,
|
||||||
|
from_client_db_id: u64,
|
||||||
|
from_name: String,
|
||||||
|
message: String,
|
||||||
|
timestamp: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit(event: &Event) {
|
fn emit(event: &Event) {
|
||||||
@@ -553,6 +585,8 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
// arrives as a StreamItem::MessageEvent (not a BookEvents batch, since log
|
// arrives as a StreamItem::MessageEvent (not a BookEvents batch, since log
|
||||||
// lines aren't part of the channel/client/server data model).
|
// lines aren't part of the channel/client/server data model).
|
||||||
let mut pending_server_log = false;
|
let mut pending_server_log = false;
|
||||||
|
let mut pending_ban_list = false;
|
||||||
|
let mut pending_complain_list = false;
|
||||||
|
|
||||||
enum LoopOutcome {
|
enum LoopOutcome {
|
||||||
StdinLine(std::io::Result<Option<String>>),
|
StdinLine(std::io::Result<Option<String>>),
|
||||||
@@ -894,6 +928,92 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
}
|
}
|
||||||
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
}
|
}
|
||||||
|
} else if l == "banlist" {
|
||||||
|
// No typed builder exists for banlist, so this is built as a raw
|
||||||
|
// command; the reply arrives via StreamItem::MessageEvent (see below).
|
||||||
|
let packet = OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "banlist");
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_ban_list = true;
|
||||||
|
pending_messages.insert(handle, "Ban list".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
} else if let Some(rest) = l.strip_prefix("bandel ") {
|
||||||
|
match rest.trim().parse::<u32>() {
|
||||||
|
Ok(ban_id) => {
|
||||||
|
let mut packet =
|
||||||
|
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "bandel");
|
||||||
|
packet.write_arg("banid", &ban_id);
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_messages.insert(handle, "Delete ban".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => emit(&Event::Error { message: format!("Invalid ban id: {rest}") }),
|
||||||
|
}
|
||||||
|
} else if l == "bandelall" {
|
||||||
|
let packet = OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "bandelall");
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_messages.insert(handle, "Delete all bans".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
} else if l == "complainlist" {
|
||||||
|
let packet =
|
||||||
|
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "complainlist");
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_complain_list = true;
|
||||||
|
pending_messages.insert(handle, "Complain list".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
} else if let Some(rest) = l.strip_prefix("complaindel ") {
|
||||||
|
let mut parts = rest.trim().splitn(2, ' ');
|
||||||
|
let target_str = parts.next().unwrap_or("");
|
||||||
|
let from_str = parts.next().unwrap_or("");
|
||||||
|
match (target_str.parse::<u64>(), from_str.parse::<u64>()) {
|
||||||
|
(Ok(tcldbid), Ok(fcldbid)) => {
|
||||||
|
let mut packet = OutCommand::new(
|
||||||
|
Direction::C2S,
|
||||||
|
Flags::empty(),
|
||||||
|
PacketType::Command,
|
||||||
|
"complaindel",
|
||||||
|
);
|
||||||
|
packet.write_arg("tcldbid", &tcldbid);
|
||||||
|
packet.write_arg("fcldbid", &fcldbid);
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_messages.insert(handle, "Delete complaint".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => emit(&Event::Error { message: format!("Invalid complaindel args: {rest}") }),
|
||||||
|
}
|
||||||
|
} else if let Some(rest) = l.strip_prefix("complaindelall ") {
|
||||||
|
match rest.trim().parse::<u64>() {
|
||||||
|
Ok(tcldbid) => {
|
||||||
|
let mut packet = OutCommand::new(
|
||||||
|
Direction::C2S,
|
||||||
|
Flags::empty(),
|
||||||
|
PacketType::Command,
|
||||||
|
"complaindelall",
|
||||||
|
);
|
||||||
|
packet.write_arg("tcldbid", &tcldbid);
|
||||||
|
match packet.send_with_result(&mut con) {
|
||||||
|
Ok(handle) => {
|
||||||
|
pending_messages.insert(handle, "Delete all complaints for client".into());
|
||||||
|
}
|
||||||
|
Err(e) => emit(&Event::Error { message: e.to_string() }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => emit(&Event::Error { message: format!("Invalid client db id: {rest}") }),
|
||||||
|
}
|
||||||
} else if let Some(b64) = l.strip_prefix("audio ") {
|
} else if let Some(b64) = l.strip_prefix("audio ") {
|
||||||
match base64::engine::general_purpose::STANDARD.decode(b64.trim()) {
|
match base64::engine::general_purpose::STANDARD.decode(b64.trim()) {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
@@ -1075,6 +1195,44 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
pending_server_log = false;
|
pending_server_log = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if pending_ban_list {
|
||||||
|
if let InMessage::BanList(list) = &msg {
|
||||||
|
let entries: Vec<BanListEntry> = list
|
||||||
|
.iter()
|
||||||
|
.map(|part| BanListEntry {
|
||||||
|
ban_id: part.ban_id,
|
||||||
|
ip: part.ip.to_string(),
|
||||||
|
name: part.name.clone(),
|
||||||
|
uid: part.uid.to_string(),
|
||||||
|
last_nickname: part.last_nickname.clone(),
|
||||||
|
created: part.created.to_string(),
|
||||||
|
duration_secs: part.duration.whole_seconds(),
|
||||||
|
invoker_name: part.invoker_name.clone(),
|
||||||
|
reason: part.reason.clone(),
|
||||||
|
enforcements: part.enforcements,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
emit(&Event::BanList { entries });
|
||||||
|
pending_ban_list = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if pending_complain_list {
|
||||||
|
if let InMessage::ComplainList(list) = &msg {
|
||||||
|
let entries: Vec<ComplainListEntry> = list
|
||||||
|
.iter()
|
||||||
|
.map(|part| ComplainListEntry {
|
||||||
|
target_client_db_id: part.target_client_db_id.0,
|
||||||
|
target_name: part.target_name.clone(),
|
||||||
|
from_client_db_id: part.from_client_db_id.0,
|
||||||
|
from_name: part.from_name.clone(),
|
||||||
|
message: part.message.clone(),
|
||||||
|
timestamp: part.timestamp.to_string(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
emit(&Event::ComplainList { entries });
|
||||||
|
pending_complain_list = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(Ok(_)) => {}
|
Some(Ok(_)) => {}
|
||||||
Some(Err(e)) => {
|
Some(Err(e)) => {
|
||||||
|
|||||||
@@ -150,6 +150,30 @@ wss.on("connection", (socket: WebSocket) => {
|
|||||||
await connection?.getServerLog();
|
await connection?.getServerLog();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "getBanList": {
|
||||||
|
await connection?.getBanList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteBan": {
|
||||||
|
await connection?.deleteBan(msg.banId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteAllBans": {
|
||||||
|
await connection?.deleteAllBans();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "getComplainList": {
|
||||||
|
await connection?.getComplainList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteComplaint": {
|
||||||
|
await connection?.deleteComplaint(msg.targetClientDbId, msg.fromClientDbId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteAllComplaintsFor": {
|
||||||
|
await connection?.deleteAllComplaintsFor(msg.targetClientDbId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "disconnect": {
|
case "disconnect": {
|
||||||
await connection?.disconnect(msg.message ?? "");
|
await connection?.disconnect(msg.message ?? "");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,6 +35,28 @@ export interface ClientInfo {
|
|||||||
uid: string;
|
uid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BanListEntry {
|
||||||
|
banId: number;
|
||||||
|
ip: string;
|
||||||
|
name: string;
|
||||||
|
uid: string;
|
||||||
|
lastNickname: string;
|
||||||
|
created: string;
|
||||||
|
durationSecs: number;
|
||||||
|
invokerName: string;
|
||||||
|
reason: string;
|
||||||
|
enforcements: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ComplainListEntry {
|
||||||
|
targetClientDbId: number;
|
||||||
|
targetName: string;
|
||||||
|
fromClientDbId: number;
|
||||||
|
fromName: string;
|
||||||
|
message: string;
|
||||||
|
timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type ServerLogEntry =
|
export type ServerLogEntry =
|
||||||
| { kind: "clientJoin"; client: string; channel: string }
|
| { kind: "clientJoin"; client: string; channel: string }
|
||||||
| { kind: "clientLeave"; client: string }
|
| { kind: "clientLeave"; client: string }
|
||||||
@@ -91,7 +113,9 @@ export type Ts3ConnectionEvent =
|
|||||||
bandwidthSentLastSecond: number;
|
bandwidthSentLastSecond: number;
|
||||||
bandwidthReceivedLastSecond: number;
|
bandwidthReceivedLastSecond: number;
|
||||||
}
|
}
|
||||||
| { type: "serverProtocolLog"; lines: string[] };
|
| { type: "serverProtocolLog"; lines: string[] }
|
||||||
|
| { type: "banList"; entries: BanListEntry[] }
|
||||||
|
| { type: "complainList"; entries: ComplainListEntry[] };
|
||||||
|
|
||||||
export interface Ts3ConnectOptions {
|
export interface Ts3ConnectOptions {
|
||||||
host: string;
|
host: string;
|
||||||
@@ -207,7 +231,33 @@ export class Ts3Connection {
|
|||||||
bandwidth_sent_last_second: number;
|
bandwidth_sent_last_second: number;
|
||||||
bandwidth_received_last_second: number;
|
bandwidth_received_last_second: number;
|
||||||
}
|
}
|
||||||
| { type: "serverProtocolLog"; lines: string[] };
|
| { type: "serverProtocolLog"; lines: string[] }
|
||||||
|
| {
|
||||||
|
type: "banList";
|
||||||
|
entries: {
|
||||||
|
ban_id: number;
|
||||||
|
ip: string;
|
||||||
|
name: string;
|
||||||
|
uid: string;
|
||||||
|
last_nickname: string;
|
||||||
|
created: string;
|
||||||
|
duration_secs: number;
|
||||||
|
invoker_name: string;
|
||||||
|
reason: string;
|
||||||
|
enforcements: number;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "complainList";
|
||||||
|
entries: {
|
||||||
|
target_client_db_id: number;
|
||||||
|
target_name: string;
|
||||||
|
from_client_db_id: number;
|
||||||
|
from_name: string;
|
||||||
|
message: string;
|
||||||
|
timestamp: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
|
||||||
if (event.type === "connected") {
|
if (event.type === "connected") {
|
||||||
this.emit({
|
this.emit({
|
||||||
@@ -281,6 +331,34 @@ export class Ts3Connection {
|
|||||||
bandwidthSentLastSecond: event.bandwidth_sent_last_second,
|
bandwidthSentLastSecond: event.bandwidth_sent_last_second,
|
||||||
bandwidthReceivedLastSecond: event.bandwidth_received_last_second,
|
bandwidthReceivedLastSecond: event.bandwidth_received_last_second,
|
||||||
});
|
});
|
||||||
|
} else if (event.type === "banList") {
|
||||||
|
this.emit({
|
||||||
|
type: "banList",
|
||||||
|
entries: event.entries.map((e) => ({
|
||||||
|
banId: e.ban_id,
|
||||||
|
ip: e.ip,
|
||||||
|
name: e.name,
|
||||||
|
uid: e.uid,
|
||||||
|
lastNickname: e.last_nickname,
|
||||||
|
created: e.created,
|
||||||
|
durationSecs: e.duration_secs,
|
||||||
|
invokerName: e.invoker_name,
|
||||||
|
reason: e.reason,
|
||||||
|
enforcements: e.enforcements,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
} else if (event.type === "complainList") {
|
||||||
|
this.emit({
|
||||||
|
type: "complainList",
|
||||||
|
entries: event.entries.map((e) => ({
|
||||||
|
targetClientDbId: e.target_client_db_id,
|
||||||
|
targetName: e.target_name,
|
||||||
|
fromClientDbId: e.from_client_db_id,
|
||||||
|
fromName: e.from_name,
|
||||||
|
message: e.message,
|
||||||
|
timestamp: e.timestamp,
|
||||||
|
})),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.emit(event);
|
this.emit(event);
|
||||||
}
|
}
|
||||||
@@ -357,6 +435,30 @@ export class Ts3Connection {
|
|||||||
this.child?.stdin.write(`serverlog\n`);
|
this.child?.stdin.write(`serverlog\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBanList(): Promise<void> {
|
||||||
|
this.child?.stdin.write(`banlist\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteBan(banId: number): Promise<void> {
|
||||||
|
this.child?.stdin.write(`bandel ${banId}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteAllBans(): Promise<void> {
|
||||||
|
this.child?.stdin.write(`bandelall\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getComplainList(): Promise<void> {
|
||||||
|
this.child?.stdin.write(`complainlist\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteComplaint(targetClientDbId: number, fromClientDbId: number): Promise<void> {
|
||||||
|
this.child?.stdin.write(`complaindel ${targetClientDbId} ${fromClientDbId}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteAllComplaintsFor(targetClientDbId: number): Promise<void> {
|
||||||
|
this.child?.stdin.write(`complaindelall ${targetClientDbId}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
async sendChatMessage(message: string): Promise<void> {
|
async sendChatMessage(message: string): Promise<void> {
|
||||||
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
||||||
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);
|
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);
|
||||||
|
|||||||
@@ -1058,6 +1058,35 @@
|
|||||||
width: 640px;
|
width: 640px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ts-ban-list-dialog,
|
||||||
|
.ts-complain-list-dialog {
|
||||||
|
width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-ban-list-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-ban-list-table th,
|
||||||
|
.ts-ban-list-table td {
|
||||||
|
text-align: left;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-bottom: 1px solid var(--border-soft);
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-ban-list-table th {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-dialog-buttons-left {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.ts-server-protocol-log-line {
|
.ts-server-protocol-log-line {
|
||||||
padding: 0.15rem 0.4rem;
|
padding: 0.15rem 0.4rem;
|
||||||
border-bottom: 1px solid var(--border-soft);
|
border-bottom: 1px solid var(--border-soft);
|
||||||
|
|||||||
+269
-11
@@ -181,6 +181,28 @@ interface WhisperLogEntry {
|
|||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BanListEntry {
|
||||||
|
banId: number;
|
||||||
|
ip: string;
|
||||||
|
name: string;
|
||||||
|
uid: string;
|
||||||
|
lastNickname: string;
|
||||||
|
created: string;
|
||||||
|
durationSecs: number;
|
||||||
|
invokerName: string;
|
||||||
|
reason: string;
|
||||||
|
enforcements: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ComplainListEntry {
|
||||||
|
targetClientDbId: number;
|
||||||
|
targetName: string;
|
||||||
|
fromClientDbId: number;
|
||||||
|
fromName: string;
|
||||||
|
message: string;
|
||||||
|
timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
type ContactCategory = "acquaintance" | "blocked" | "friend";
|
type ContactCategory = "acquaintance" | "blocked" | "friend";
|
||||||
|
|
||||||
interface Contact {
|
interface Contact {
|
||||||
@@ -1198,6 +1220,165 @@ function ClientLogDialog({ entries, onClose }: { entries: ClientLogEntry[]; onCl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function BanListDialog({
|
||||||
|
entries,
|
||||||
|
onDelete,
|
||||||
|
onDeleteAll,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
entries: BanListEntry[] | null;
|
||||||
|
onDelete: (banId: number) => void;
|
||||||
|
onDeleteAll: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const t = useT();
|
||||||
|
const backdrop = useBackdropDismiss(onClose);
|
||||||
|
// Same silent-decline story as connection-info/server-log: a guest account
|
||||||
|
// without b_virtualserver_client_dblist/banlist permission never gets a reply.
|
||||||
|
const [timedOut, setTimedOut] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
setTimedOut(false);
|
||||||
|
if (entries) return;
|
||||||
|
const id = window.setTimeout(() => setTimedOut(true), 6000);
|
||||||
|
return () => window.clearTimeout(id);
|
||||||
|
}, [entries]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||||
|
<div className="ts-dialog ts-ban-list-dialog" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<div className="ts-dialog-titlebar">
|
||||||
|
<span>{t("banList.title")}</span>
|
||||||
|
<button onClick={onClose} title={t("dialog.close")}>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="ts-dialog-body">
|
||||||
|
{!entries ? (
|
||||||
|
<div className="ts-connection-info-loading">
|
||||||
|
{timedOut ? t("connectionInfo.unavailable") : t("connectionInfo.loading")}
|
||||||
|
</div>
|
||||||
|
) : entries.length === 0 ? (
|
||||||
|
<div className="ts-connection-info-loading">{t("banList.empty")}</div>
|
||||||
|
) : (
|
||||||
|
<table className="ts-ban-list-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{t("banList.name")}</th>
|
||||||
|
<th>{t("banList.ip")}</th>
|
||||||
|
<th>{t("banList.created")}</th>
|
||||||
|
<th>{t("banList.duration")}</th>
|
||||||
|
<th>{t("banList.invoker")}</th>
|
||||||
|
<th>{t("banList.reason")}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{entries.map((e) => (
|
||||||
|
<tr key={e.banId}>
|
||||||
|
<td>{e.name || e.lastNickname || "-"}</td>
|
||||||
|
<td>{e.ip || "-"}</td>
|
||||||
|
<td>{e.created}</td>
|
||||||
|
<td>{e.durationSecs === 0 ? t("banList.permanent") : `${e.durationSecs}s`}</td>
|
||||||
|
<td>{e.invokerName}</td>
|
||||||
|
<td>{e.reason}</td>
|
||||||
|
<td>
|
||||||
|
<button onClick={() => onDelete(e.banId)}>{t("banList.delete")}</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="ts-dialog-buttons">
|
||||||
|
<div className="ts-dialog-buttons-left">
|
||||||
|
{entries && entries.length > 0 && (
|
||||||
|
<button onClick={onDeleteAll}>{t("banList.deleteAll")}</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="ts-dialog-buttons-right">
|
||||||
|
<button onClick={onClose}>{t("dialog.close")}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ComplainListDialog({
|
||||||
|
entries,
|
||||||
|
onDelete,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
entries: ComplainListEntry[] | null;
|
||||||
|
onDelete: (targetClientDbId: number, fromClientDbId: number) => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const t = useT();
|
||||||
|
const backdrop = useBackdropDismiss(onClose);
|
||||||
|
const [timedOut, setTimedOut] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
setTimedOut(false);
|
||||||
|
if (entries) return;
|
||||||
|
const id = window.setTimeout(() => setTimedOut(true), 6000);
|
||||||
|
return () => window.clearTimeout(id);
|
||||||
|
}, [entries]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||||
|
<div className="ts-dialog ts-complain-list-dialog" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<div className="ts-dialog-titlebar">
|
||||||
|
<span>{t("complainList.title")}</span>
|
||||||
|
<button onClick={onClose} title={t("dialog.close")}>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="ts-dialog-body">
|
||||||
|
{!entries ? (
|
||||||
|
<div className="ts-connection-info-loading">
|
||||||
|
{timedOut ? t("connectionInfo.unavailable") : t("connectionInfo.loading")}
|
||||||
|
</div>
|
||||||
|
) : entries.length === 0 ? (
|
||||||
|
<div className="ts-connection-info-loading">{t("complainList.empty")}</div>
|
||||||
|
) : (
|
||||||
|
<table className="ts-ban-list-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{t("complainList.target")}</th>
|
||||||
|
<th>{t("complainList.from")}</th>
|
||||||
|
<th>{t("complainList.message")}</th>
|
||||||
|
<th>{t("complainList.timestamp")}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{entries.map((e, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
<td>{e.targetName}</td>
|
||||||
|
<td>{e.fromName}</td>
|
||||||
|
<td>{e.message}</td>
|
||||||
|
<td>{e.timestamp}</td>
|
||||||
|
<td>
|
||||||
|
<button onClick={() => onDelete(e.targetClientDbId, e.fromClientDbId)}>
|
||||||
|
{t("banList.delete")}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="ts-dialog-buttons">
|
||||||
|
<div className="ts-dialog-buttons-right">
|
||||||
|
<button onClick={onClose}>{t("dialog.close")}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function ServerProtocolLogDialog({
|
function ServerProtocolLogDialog({
|
||||||
lines,
|
lines,
|
||||||
onClose,
|
onClose,
|
||||||
@@ -2676,6 +2857,10 @@ function AppInner() {
|
|||||||
const [serverEditOpen, setServerEditOpen] = useState(false);
|
const [serverEditOpen, setServerEditOpen] = useState(false);
|
||||||
const [serverProtocolLogOpen, setServerProtocolLogOpen] = useState(false);
|
const [serverProtocolLogOpen, setServerProtocolLogOpen] = useState(false);
|
||||||
const [serverProtocolLog, setServerProtocolLog] = useState<string[] | null>(null);
|
const [serverProtocolLog, setServerProtocolLog] = useState<string[] | null>(null);
|
||||||
|
const [banListOpen, setBanListOpen] = useState(false);
|
||||||
|
const [banList, setBanList] = useState<BanListEntry[] | null>(null);
|
||||||
|
const [complainListOpen, setComplainListOpen] = useState(false);
|
||||||
|
const [complainList, setComplainList] = useState<ComplainListEntry[] | null>(null);
|
||||||
const [treeWidth, setTreeWidth] = useState(260);
|
const [treeWidth, setTreeWidth] = useState(260);
|
||||||
const [upperHeight, setUpperHeight] = useState(340);
|
const [upperHeight, setUpperHeight] = useState(340);
|
||||||
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||||
@@ -3240,6 +3425,12 @@ function AppInner() {
|
|||||||
case "serverProtocolLog":
|
case "serverProtocolLog":
|
||||||
setServerProtocolLog(data.lines);
|
setServerProtocolLog(data.lines);
|
||||||
break;
|
break;
|
||||||
|
case "banList":
|
||||||
|
setBanList(data.entries);
|
||||||
|
break;
|
||||||
|
case "complainList":
|
||||||
|
setComplainList(data.entries);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3816,6 +4007,41 @@ function AppInner() {
|
|||||||
socketRef.current?.send(JSON.stringify({ type: "getServerLog" }));
|
socketRef.current?.send(JSON.stringify({ type: "getServerLog" }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleShowBanList = () => {
|
||||||
|
setBanListOpen(true);
|
||||||
|
setBanList(null);
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "getBanList" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteBan = (banId: number) => {
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "deleteBan", banId }));
|
||||||
|
setBanList((prev) => (prev ? prev.filter((e) => e.banId !== banId) : prev));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteAllBans = () => {
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "deleteAllBans" }));
|
||||||
|
setBanList([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleShowComplainList = () => {
|
||||||
|
setComplainListOpen(true);
|
||||||
|
setComplainList(null);
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "getComplainList" }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteComplaint = (targetClientDbId: number, fromClientDbId: number) => {
|
||||||
|
socketRef.current?.send(
|
||||||
|
JSON.stringify({ type: "deleteComplaint", targetClientDbId, fromClientDbId })
|
||||||
|
);
|
||||||
|
setComplainList((prev) =>
|
||||||
|
prev
|
||||||
|
? prev.filter(
|
||||||
|
(e) => !(e.targetClientDbId === targetClientDbId && e.fromClientDbId === fromClientDbId)
|
||||||
|
)
|
||||||
|
: prev
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleClientContextMenu = (
|
const handleClientContextMenu = (
|
||||||
e: React.MouseEvent,
|
e: React.MouseEvent,
|
||||||
clientId: number,
|
clientId: number,
|
||||||
@@ -4174,17 +4400,32 @@ function AppInner() {
|
|||||||
<span className="ts-menu-item-shortcut">Strg+L</span>
|
<span className="ts-menu-item-shortcut">Strg+L</span>
|
||||||
</button>
|
</button>
|
||||||
<div className="ts-menu-separator" />
|
<div className="ts-menu-separator" />
|
||||||
{[
|
<button
|
||||||
{ icon: "🚫", label: t("menu.extras.banList"), shortcut: "Strg+Umschalt+B" },
|
className="ts-menu-item"
|
||||||
{ icon: "⚠️", label: t("menu.extras.complaintList"), shortcut: "Strg+Umschalt+C" },
|
onClick={() => {
|
||||||
{ icon: "🔑", label: t("menu.extras.serverQueryLogin") },
|
handleShowBanList();
|
||||||
].map((item) => (
|
setExtrasMenuOpen(false);
|
||||||
<button key={item.label} className="ts-menu-item" disabled>
|
}}
|
||||||
<span className="ts-menu-item-icon">{item.icon}</span>
|
>
|
||||||
<span className="ts-menu-item-label">{item.label}</span>
|
<span className="ts-menu-item-icon">🚫</span>
|
||||||
{item.shortcut && <span className="ts-menu-item-shortcut">{item.shortcut}</span>}
|
<span className="ts-menu-item-label">{t("menu.extras.banList")}</span>
|
||||||
</button>
|
<span className="ts-menu-item-shortcut">Strg+Umschalt+B</span>
|
||||||
))}
|
</button>
|
||||||
|
<button
|
||||||
|
className="ts-menu-item"
|
||||||
|
onClick={() => {
|
||||||
|
handleShowComplainList();
|
||||||
|
setExtrasMenuOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="ts-menu-item-icon">⚠️</span>
|
||||||
|
<span className="ts-menu-item-label">{t("menu.extras.complaintList")}</span>
|
||||||
|
<span className="ts-menu-item-shortcut">Strg+Umschalt+C</span>
|
||||||
|
</button>
|
||||||
|
<button className="ts-menu-item" disabled>
|
||||||
|
<span className="ts-menu-item-icon">🔑</span>
|
||||||
|
<span className="ts-menu-item-label">{t("menu.extras.serverQueryLogin")}</span>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
className="ts-menu-item"
|
className="ts-menu-item"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -4545,6 +4786,23 @@ function AppInner() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{banListOpen && (
|
||||||
|
<BanListDialog
|
||||||
|
entries={banList}
|
||||||
|
onDelete={handleDeleteBan}
|
||||||
|
onDeleteAll={handleDeleteAllBans}
|
||||||
|
onClose={() => setBanListOpen(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{complainListOpen && (
|
||||||
|
<ComplainListDialog
|
||||||
|
entries={complainList}
|
||||||
|
onDelete={handleDeleteComplaint}
|
||||||
|
onClose={() => setComplainListOpen(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{contactsOpen && (
|
{contactsOpen && (
|
||||||
<ContactsDialog
|
<ContactsDialog
|
||||||
contacts={contacts}
|
contacts={contacts}
|
||||||
|
|||||||
@@ -215,6 +215,66 @@ export class DemoSocket {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "getBanList": {
|
||||||
|
this.after(400, () =>
|
||||||
|
this.emit({
|
||||||
|
type: "banList",
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
banId: 1,
|
||||||
|
ip: "203.0.113.42",
|
||||||
|
name: "TrollUser",
|
||||||
|
uid: "demo-uid-troll",
|
||||||
|
lastNickname: "TrollUser",
|
||||||
|
created: "2026-07-28 14:02:11",
|
||||||
|
durationSecs: 0,
|
||||||
|
invokerName: "Alex",
|
||||||
|
reason: "Spamming the server chat",
|
||||||
|
enforcements: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
banId: 2,
|
||||||
|
ip: "198.51.100.7",
|
||||||
|
name: "",
|
||||||
|
uid: "demo-uid-annoying",
|
||||||
|
lastNickname: "AnnoyingGuest",
|
||||||
|
created: "2026-08-01 09:44:53",
|
||||||
|
durationSecs: 3600,
|
||||||
|
invokerName: "Sam",
|
||||||
|
reason: "Repeated channel spam",
|
||||||
|
enforcements: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteBan":
|
||||||
|
case "deleteAllBans":
|
||||||
|
// No observable effect - the frontend already optimistically removes
|
||||||
|
// the deleted row(s) from its own state.
|
||||||
|
break;
|
||||||
|
case "getComplainList": {
|
||||||
|
this.after(400, () =>
|
||||||
|
this.emit({
|
||||||
|
type: "complainList",
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
targetClientDbId: 104,
|
||||||
|
targetName: "Jordan",
|
||||||
|
fromClientDbId: 103,
|
||||||
|
fromName: "Sam",
|
||||||
|
message: "Kept talking over everyone in voice chat.",
|
||||||
|
timestamp: "2026-08-02 18:21:07",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "deleteComplaint":
|
||||||
|
case "deleteAllComplaintsFor":
|
||||||
|
break;
|
||||||
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
||||||
// App.tsx always calls socket.close() right after sending it, and
|
// App.tsx always calls socket.close() right after sending it, and
|
||||||
// close() already emits the "disconnected" event below.
|
// close() already emits the "disconnected" event below.
|
||||||
|
|||||||
@@ -358,6 +358,23 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
|
|
||||||
"serverProtocolLog.title": "Server Protokoll",
|
"serverProtocolLog.title": "Server Protokoll",
|
||||||
"serverProtocolLog.empty": "Keine Protokolleinträge vorhanden.",
|
"serverProtocolLog.empty": "Keine Protokolleinträge vorhanden.",
|
||||||
|
"banList.title": "Bannliste",
|
||||||
|
"banList.empty": "Keine Bans vorhanden.",
|
||||||
|
"banList.name": "Name",
|
||||||
|
"banList.ip": "IP",
|
||||||
|
"banList.created": "Erstellt",
|
||||||
|
"banList.duration": "Dauer",
|
||||||
|
"banList.invoker": "Von",
|
||||||
|
"banList.reason": "Grund",
|
||||||
|
"banList.permanent": "Permanent",
|
||||||
|
"banList.delete": "Löschen",
|
||||||
|
"banList.deleteAll": "Alle löschen",
|
||||||
|
"complainList.title": "Beschwerdeliste",
|
||||||
|
"complainList.empty": "Keine Beschwerden vorhanden.",
|
||||||
|
"complainList.target": "Ziel",
|
||||||
|
"complainList.from": "Von",
|
||||||
|
"complainList.message": "Nachricht",
|
||||||
|
"complainList.timestamp": "Zeitpunkt",
|
||||||
|
|
||||||
"clientContext.privateChat": "Privater Chat",
|
"clientContext.privateChat": "Privater Chat",
|
||||||
"clientContext.poke": "Anstupsen",
|
"clientContext.poke": "Anstupsen",
|
||||||
@@ -754,6 +771,23 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
|
|
||||||
"serverProtocolLog.title": "Server Log",
|
"serverProtocolLog.title": "Server Log",
|
||||||
"serverProtocolLog.empty": "No log entries.",
|
"serverProtocolLog.empty": "No log entries.",
|
||||||
|
"banList.title": "Ban List",
|
||||||
|
"banList.empty": "No bans found.",
|
||||||
|
"banList.name": "Name",
|
||||||
|
"banList.ip": "IP",
|
||||||
|
"banList.created": "Created",
|
||||||
|
"banList.duration": "Duration",
|
||||||
|
"banList.invoker": "By",
|
||||||
|
"banList.reason": "Reason",
|
||||||
|
"banList.permanent": "Permanent",
|
||||||
|
"banList.delete": "Delete",
|
||||||
|
"banList.deleteAll": "Delete all",
|
||||||
|
"complainList.title": "Complaint List",
|
||||||
|
"complainList.empty": "No complaints found.",
|
||||||
|
"complainList.target": "Target",
|
||||||
|
"complainList.from": "From",
|
||||||
|
"complainList.message": "Message",
|
||||||
|
"complainList.timestamp": "Timestamp",
|
||||||
|
|
||||||
"clientContext.privateChat": "Private chat",
|
"clientContext.privateChat": "Private chat",
|
||||||
"clientContext.poke": "Poke",
|
"clientContext.poke": "Poke",
|
||||||
|
|||||||
Reference in new issue
Block a user