Make upstreamConn.produce log messages

This commit is contained in:
Simon Ser 2020-04-06 21:42:55 +02:00
parent baadb964bc
commit 9692114f37
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 9 additions and 10 deletions

View File

@ -1186,8 +1186,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
Params: []string{upstreamName, text},
}
uc.appendLog(upstreamName, echoMsg)
uc.produce(echoMsg, dc)
uc.produce(upstreamName, echoMsg, dc)
}
case "NOTICE":
var targetsStr, text string

View File

@ -247,7 +247,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
return nil
case "NOTICE":
if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
uc.produce(msg, nil)
uc.produce("", msg, nil)
} else { // regular user NOTICE
var entity, text string
if err := parseMessageParams(msg, &entity, &text); err != nil {
@ -258,9 +258,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
if target == uc.nick {
target = msg.Prefix.Name
}
uc.appendLog(target, msg)
uc.produce(msg, nil)
uc.produce(target, msg, nil)
}
case "CAP":
var subCmd string
@ -1134,9 +1132,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
if target == uc.nick {
target = msg.Prefix.Name
}
uc.appendLog(target, msg)
uc.produce(msg, nil)
uc.produce(target, msg, nil)
case "INVITE":
var nick string
var channel string
@ -1364,7 +1360,11 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) {
}
}
func (uc *upstreamConn) produce(msg *irc.Message, origin *downstreamConn) {
func (uc *upstreamConn) produce(target string, msg *irc.Message, origin *downstreamConn) {
if target != "" {
uc.appendLog(target, msg)
}
uc.network.ring.Produce(msg)
uc.forEachDownstream(func(dc *downstreamConn) {