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 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user