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
+11 -8
View File
@@ -1208,11 +1208,12 @@ func insertMessageInTx(
return dbID, msgUUID, nil
}
// EnqueueToSession adds a message to all clients of a
// session's queues.
// EnqueueToSession adds a message to the queues of all
// clients of a session except client skipClientID, or of all
// of them when skipClientID is 0.
func (database *Database) EnqueueToSession(
ctx context.Context,
sessionID, messageID int64,
sessionID, messageID, skipClientID int64,
) error {
transaction, err := database.conn.BeginTx(ctx, nil)
if err != nil {
@@ -1221,7 +1222,9 @@ func (database *Database) EnqueueToSession(
defer func() { _ = transaction.Rollback() }()
err = enqueueToSessionInTx(ctx, transaction, sessionID, messageID)
err = enqueueToSessionInTx(
ctx, transaction, sessionID, messageID, skipClientID,
)
if err != nil {
return err
}
@@ -1239,15 +1242,15 @@ func (database *Database) EnqueueToSession(
func enqueueToSessionInTx(
ctx context.Context,
transaction *sql.Tx,
sessionID, messageID int64,
sessionID, messageID, skipClientID int64,
) error {
_, err := transaction.ExecContext(ctx,
`INSERT OR IGNORE INTO client_queues
(client_id, message_id, created_at)
SELECT c.id, ?, ?
FROM clients c
WHERE c.session_id = ?`,
messageID, time.Now(), sessionID)
WHERE c.session_id = ? AND c.id != ?`,
messageID, time.Now(), sessionID, skipClientID)
if err != nil {
return fmt.Errorf(
"enqueue to session: %w", err,
@@ -1673,7 +1676,7 @@ func quitSessionInTx(
for _, peerID := range peerIDs {
err = enqueueToSessionInTx(
ctx, transaction, peerID, messageID,
ctx, transaction, peerID, messageID, 0,
)
if err != nil {
return nil, err
+1 -1
View File
@@ -675,7 +675,7 @@ func TestPollMessages(t *testing.T) {
t.Fatal(err)
}
err = database.EnqueueToSession(ctx, sid, dbID)
err = database.EnqueueToSession(ctx, sid, dbID, 0)
if err != nil {
t.Fatal(err)
}