Show an IRC listener user what their session sends from other clients (closes #179)
check / check (push) Waiting to run
check / check (push) Waiting to run
The IRC listener's relay dropped every line sent under the connection's own nick, so a user on the web client and an IRC client at once never saw on IRC what they did from the web client. The relay now drops nothing by nick. Instead the fan-out skips only the sending client's own queue: the IRC listener passes its own client, whose handler already wrote the echo, and the HTTP API skips none. Channel messages and PARTs now reach the sender's other clients, so an HTTP client gets its own PART event; neoirc-cli ignores it, as it already shows its own part. README.md names the commands covered. Judgement call: a PRIVMSG or NOTICE sent on an IRC connection is not echoed back to it, as in IRC. Model: opus-5-5
This commit was merged in pull request #183.
This commit is contained in:
+11
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user