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}, Params: []string{upstreamName, text},
} }
uc.appendLog(upstreamName, echoMsg) uc.produce(upstreamName, echoMsg, dc)
uc.produce(echoMsg, dc)
} }
case "NOTICE": case "NOTICE":
var targetsStr, text string var targetsStr, text string

View File

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