Add origin argument to upstreamConn.produce

This commit is contained in:
Simon Ser 2020-04-06 21:34:45 +02:00
parent b1494e1065
commit baadb964bc
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 8 additions and 13 deletions

View File

@ -1187,14 +1187,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
}
uc.appendLog(upstreamName, echoMsg)
uc.network.ring.Produce(echoMsg)
uc.forEachDownstream(func(c *downstreamConn) {
if c != dc || c.caps["echo-message"] {
c.sendFromUpstream(echoMsg, uc)
}
})
uc.produce(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)
uc.produce(msg, nil)
} else { // regular user NOTICE
var entity, text string
if err := parseMessageParams(msg, &entity, &text); err != nil {
@ -260,7 +260,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}
uc.appendLog(target, msg)
uc.produce(msg)
uc.produce(msg, nil)
}
case "CAP":
var subCmd string
@ -1136,7 +1136,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}
uc.appendLog(target, msg)
uc.produce(msg)
uc.produce(msg, nil)
case "INVITE":
var nick string
var channel string
@ -1364,11 +1364,13 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) {
}
}
func (uc *upstreamConn) produce(msg *irc.Message) {
func (uc *upstreamConn) produce(msg *irc.Message, origin *downstreamConn) {
uc.network.ring.Produce(msg)
uc.forEachDownstream(func(dc *downstreamConn) {
dc.sendFromUpstream(msg, uc)
if dc != origin || dc.caps["echo-message"] {
dc.sendFromUpstream(msg, uc)
}
})
}