feat: enhance message broadcasting to exclude sender's connection and improve IRC compliance

This commit is contained in:
HueByte
2026-07-17 17:05:03 +02:00
parent 953e081123
commit 96736d69df
9 changed files with 47 additions and 16 deletions
+6 -3
View File
@@ -14,7 +14,7 @@ public class IrcBroadcaster : IChatBroadcaster
_encryption = encryption;
}
public async Task SendMessageToChannelAsync(string channelName, MessageDto message)
public async Task SendMessageToChannelAsync(string channelName, MessageDto message, string? excludeConnectionId = null)
{
// Decrypt transport-encrypted content for IRC clients (they can't handle
// app-layer encryption). E2E room ciphertext ($RC1$) passes through untouched.
@@ -23,8 +23,11 @@ public class IrcBroadcaster : IChatBroadcaster
foreach (var conn in _gateway.GetConnectionsInChannel(channelName))
{
// IRC convention: don't echo sender's own message
if (conn.Nickname == message.SenderUsername)
// IRC convention: don't echo a message back to the connection that sent it
// (its client already displayed it locally). Match by connection id, not
// nickname — the same account may also be online via the TUI or a second
// IRC client, and those sessions must still receive the message.
if (conn.ConnectionId == excludeConnectionId)
continue;
foreach (var line in lines)