From 1a3a3e37c14774aa5a14f2c37c9c39f91ec4e0d1 Mon Sep 17 00:00:00 2001 From: ericek111 Date: Fri, 25 Sep 2026 10:51:24 +0000 Subject: [PATCH] Write both kinds of chat message through one method appendMessage and appendPrivateMessage built the same entry twice; they now differ only in which log they pick. Co-Authored-By: Claude Opus 5.5 --- .../com/ts3client/chatlog/ChatLogStore.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ts3-client/core/src/main/java/com/ts3client/chatlog/ChatLogStore.java b/ts3-client/core/src/main/java/com/ts3client/chatlog/ChatLogStore.java index 13e0f63..8c5d36a 100644 --- a/ts3-client/core/src/main/java/com/ts3client/chatlog/ChatLogStore.java +++ b/ts3-client/core/src/main/java/com/ts3client/chatlog/ChatLogStore.java @@ -103,9 +103,23 @@ public final class ChatLogStore { return new SearchResult(last(hits, limit), hits.size()); } + /** Logs a message; a private one goes to the log of the client it came from. */ public synchronized String appendMessage(ChatLogScope scope, boolean outgoing, int clientId, String uniqueId, String nickname, String message) throws IOException { LogFiles files = scope == ChatLogScope.PRIVATE ? privateLog(uniqueId) : log(scope); + return append(files, scope, outgoing, clientId, uniqueId, nickname, message); + } + + /** Logs a private message in the conversation with {@code peerUniqueId}, whoever wrote it. */ + public synchronized String appendPrivateMessage(String peerUniqueId, boolean outgoing, int clientId, + String uniqueId, String nickname, String message) + throws IOException { + return append(privateLog(peerUniqueId), ChatLogScope.PRIVATE, outgoing, clientId, uniqueId, nickname, + message); + } + + private String append(LogFiles files, ChatLogScope scope, boolean outgoing, int clientId, String uniqueId, + String nickname, String message) throws IOException { LocalDateTime now = LocalDateTime.now(); String text = "<" + TIME.format(now) + "> " + safe(nickname) + ": " + safe(message); String html = messageHtml(scope, outgoing, now, clientId, uniqueId, nickname, message); @@ -113,16 +127,6 @@ public final class ChatLogStore { return html; } - public synchronized String appendPrivateMessage(String peerUniqueId, boolean outgoing, int clientId, - String uniqueId, String nickname, String message) - throws IOException { - LocalDateTime now = LocalDateTime.now(); - String text = "<" + TIME.format(now) + "> " + safe(nickname) + ": " + safe(message); - String html = messageHtml(ChatLogScope.PRIVATE, outgoing, now, clientId, uniqueId, nickname, message); - appendRaw(privateLog(peerUniqueId), text, html); - return html; - } - public synchronized String appendServerEvent(String message) throws IOException { LocalDateTime now = LocalDateTime.now(); String text = "<" + TIME.format(now) + "> " + safe(message);