fix: show channel broadcast messages

This commit is contained in:
illusia committed 2026-09-03 16:08:51 +08:00
1 parent 83a8fd0d5a
commit 767bdea018
3 files changed
+13 -5

No files matched your search

+7 -3
View File
@@ -484,12 +484,16 @@ export class VoiceBridge {
tsClient.on("textMessage", (message) => {
const scope = message.targetMode === 1 ? "private" : message.targetMode === 3 ? "server" : message.targetMode === 2 ? "channel" : "server";
const targetId = message.targetId ?? 0n;
// TeamSpeak channel notifications omit `target`; the SDK represents
// that as 0. Bind the broadcast to this session's current channel so
// it remains visible now but cannot leak into another channel after a
// later channel switch.
const effectiveTargetId = scope === "channel" && targetId === 0n ? tsClient.getChannelId() : targetId;
sendJson({
type: "chatMessage",
scope,
// Keep event handling total: malformed/legacy SDK events must not
// throw from this callback and tear down the browser session.
targetId: String(message.targetId ?? 0n),
...(effectiveTargetId !== 0n ? { targetId: String(effectiveTargetId) } : {}),
senderUid: message.invokerUid,
timestamp: Date.now(),
invokerName: message.invokerName,
+5 -1
View File
@@ -1150,10 +1150,14 @@ export function useVoiceWebSocket() {
case "chatMessage":
if (Number(msg.invokerId) === state.tsClientId) break;
const incomingScope = msg.scope === "private" || msg.scope === "server" || msg.scope === "channel" ? msg.scope : "system";
const rawTargetId = typeof msg.targetId === "string" || typeof msg.targetId === "number" ? String(msg.targetId) : undefined;
// Older gateways and TeamSpeak channel notifications may use 0 as
// the broadcast sentinel. It must not be compared with a channel id.
const incomingTargetId = rawTargetId && rawTargetId !== "0" ? rawTargetId : undefined;
chatMessages.push({
id: `remote-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
scope: incomingScope,
targetId: typeof msg.targetId === "string" ? msg.targetId : undefined,
...(incomingTargetId ? { targetId: incomingTargetId } : {}),
...(incomingScope === "private" ? { conversationId: String(Number(msg.invokerId) || 0) } : {}),
senderId: Number(msg.invokerId) || undefined,
senderUid: typeof msg.senderUid === "string" ? msg.senderUid : undefined,
+1 -1
View File
@@ -937,7 +937,7 @@ const visibleChatMessages = computed(() => {
if (chatTab.value === "private") return chatMessages.filter((message) => message.scope === "private" && message.conversationId === String(privateClientId.value));
if (chatTab.value !== "channel") return [];
const channelId = currentChannel.value?.id;
return chatMessages.filter((message) => message.scope === "channel" && (!message.targetId || !channelId || message.targetId === channelId));
return chatMessages.filter((message) => message.scope === "channel" && (!message.targetId || message.targetId === "0" || !channelId || message.targetId === channelId));
});
const chatTabLabel = computed(() => chatTab.value === "channel" ? t("textChannel") : chatTab.value === "server" ? t("serverChat") : chatTab.value === "private" ? t("privateMessage") : t("eventLog"));