Show an IRC listener user what their session sends from other clients (closes #179)
check / check (push) Canceled after 0s

The relay dropped every PRIVMSG, NOTICE, JOIN, PART, NICK, QUIT, TOPIC,
MODE and KICK sent under the connection's own nick, so an IRC listener
connection never saw what its session did from another client. The
relay now drops nothing by nick. Instead, the service methods that fan
out a user's own command take the client whose queue to skip: the IRC
listener passes its own client, which has already written the echo, and
the HTTP API passes 0. Channel messages and PARTs now also go to the
sender's own session, so the HTTP handler no longer queues the
channel-message echo itself and SendChannelMessage no longer returns
the message's row ID.

Model: opus-5-5
This commit is contained in:
2026-10-21 11:24:32 +00:00
parent d539b4c558
commit 083d2073bb
11 changed files with 385 additions and 243 deletions
+14 -19
View File
@@ -1257,9 +1257,11 @@ func (hdlr *Handlers) handleChannelMsg(
) {
ctx := request.Context()
// Delegate validation + fan-out to service layer.
dbID, uuid, err := hdlr.svc.SendChannelMessage(
ctx, sessionID, nick,
// Delegate validation + fan-out to service layer. The
// fan-out includes the sender's own session, so all
// their clients see the message in long-poll responses.
uuid, err := hdlr.svc.SendChannelMessage(
ctx, sessionID, 0, nick,
command, target, body, meta,
)
if hdlr.handleServiceError(
@@ -1269,13 +1271,6 @@ func (hdlr *Handlers) handleChannelMsg(
return
}
// HTTP echo: enqueue to sender so all their clients
// see the message in long-poll responses.
_ = hdlr.params.Database.EnqueueToSession(
ctx, sessionID, dbID,
)
hdlr.broker.Notify(sessionID)
hdlr.respondJSON(writer, request,
map[string]string{"id": uuid, statusKey: "sent"},
http.StatusOK)
@@ -1290,7 +1285,7 @@ func (hdlr *Handlers) handleDirectMsg(
meta json.RawMessage,
) {
result, err := hdlr.svc.SendDirectMessage(
request.Context(), sessionID, nick,
request.Context(), sessionID, 0, nick,
command, target, body, meta,
)
if hdlr.handleServiceError(
@@ -1361,7 +1356,7 @@ func (hdlr *Handlers) executeJoin(
nick, channel, suppliedKey string,
) {
result, err := hdlr.svc.JoinChannel(
request.Context(), sessionID, nick,
request.Context(), sessionID, 0, nick,
channel, suppliedKey,
)
if hdlr.handleServiceError(
@@ -1545,7 +1540,7 @@ func (hdlr *Handlers) handlePart(
}
err := hdlr.svc.PartChannel(
request.Context(), sessionID,
request.Context(), sessionID, 0,
nick, channel, reason,
)
if hdlr.handleServiceError(
@@ -1616,7 +1611,7 @@ func (hdlr *Handlers) executeNickChange(
nick, newNick string,
) {
err := hdlr.svc.ChangeNick(
request.Context(), sessionID, nick, newNick,
request.Context(), sessionID, 0, nick, newNick,
)
if hdlr.handleServiceError(
writer, request,
@@ -1671,7 +1666,7 @@ func (hdlr *Handlers) handleTopic(
topic := strings.Join(lines, " ")
err := hdlr.svc.SetTopic(
request.Context(), sessionID,
request.Context(), sessionID, 0,
nick, channel, topic,
)
if hdlr.handleServiceError(
@@ -2157,7 +2152,7 @@ func (hdlr *Handlers) applyUserMode(
modeText := modeArgs[0] + " " + targetNick
hdlr.svc.BroadcastMode(
request.Context(), nick, channel, chID,
request.Context(), 0, nick, channel, chID,
modeText,
)
@@ -2203,7 +2198,7 @@ func (hdlr *Handlers) setChannelFlag(
}
hdlr.svc.BroadcastMode(
request.Context(), nick, channel, chID,
request.Context(), 0, nick, channel, chID,
modeStr,
)
@@ -3650,7 +3645,7 @@ func (hdlr *Handlers) handleKick(
}
err := hdlr.svc.KickUser(
request.Context(), sessionID, nick,
request.Context(), sessionID, 0, nick,
channel, targetNick, reason,
)
if hdlr.handleServiceError(
@@ -3723,7 +3718,7 @@ func (hdlr *Handlers) fanOut(
for _, sid := range sessionIDs {
enqErr := hdlr.params.Database.EnqueueToSession(
request.Context(), sid, dbID,
request.Context(), sid, dbID, 0,
)
if enqErr != nil {
hdlr.log.Error("enqueue failed",