downstream: drop downstreamConn.marshalUserPrefix

This is now a no-op.
This commit is contained in:
Simon Ser 2022-08-05 18:51:18 +02:00
parent 00919e9412
commit 25257b8892
2 changed files with 5 additions and 30 deletions

View File

@ -442,24 +442,6 @@ func (dc *downstreamConn) marshalEntity(net *network, name string) string {
return name + "/" + net.GetName() return name + "/" + net.GetName()
} }
func (dc *downstreamConn) marshalUserPrefix(net *network, prefix *irc.Prefix) *irc.Prefix {
if isOurNick(net, prefix.Name) {
return dc.prefix()
}
prefix.Name = partialCasemap(net.casemap, prefix.Name)
if dc.network != nil {
if dc.network != net {
panic("soju: tried to marshal a user prefix for another network")
}
return prefix
}
return &irc.Prefix{
Name: prefix.Name + "/" + net.GetName(),
User: prefix.User,
Host: prefix.Host,
}
}
// unmarshalEntityNetwork converts a downstream entity name (ie. channel or // unmarshalEntityNetwork converts a downstream entity name (ie. channel or
// nick) into an upstream entity name. // nick) into an upstream entity name.
// //
@ -661,7 +643,6 @@ func (dc *downstreamConn) handlePong(token string) {
// may only appear in single-upstream mode. // may only appear in single-upstream mode.
func (dc *downstreamConn) marshalMessage(msg *irc.Message, net *network) *irc.Message { func (dc *downstreamConn) marshalMessage(msg *irc.Message, net *network) *irc.Message {
msg = msg.Copy() msg = msg.Copy()
msg.Prefix = dc.marshalUserPrefix(net, msg.Prefix)
if dc.network != nil { if dc.network != nil {
return msg return msg
@ -3509,12 +3490,11 @@ func sendTopic(dc *downstreamConn, ch *upstreamChannel) {
Params: []string{dc.nick, downstreamName, ch.Topic}, Params: []string{dc.nick, downstreamName, ch.Topic},
}) })
if ch.TopicWho != nil { if ch.TopicWho != nil {
topicWho := dc.marshalUserPrefix(ch.conn.network, ch.TopicWho)
topicTime := strconv.FormatInt(ch.TopicTime.Unix(), 10) topicTime := strconv.FormatInt(ch.TopicTime.Unix(), 10)
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: xirc.RPL_TOPICWHOTIME, Command: xirc.RPL_TOPICWHOTIME,
Params: []string{dc.nick, downstreamName, topicWho.String(), topicTime}, Params: []string{dc.nick, downstreamName, ch.TopicWho.String(), topicTime},
}) })
} }
} else { } else {

View File

@ -1197,7 +1197,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
} }
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix), Prefix: msg.Prefix,
Command: "MODE", Command: "MODE",
Params: params, Params: params,
}) })
@ -1307,14 +1307,13 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
c := uc.network.channels.Get(channel) c := uc.network.channels.Get(channel)
if firstTopicWhoTime && (c == nil || !c.Detached) { if firstTopicWhoTime && (c == nil || !c.Detached) {
uc.forEachDownstream(func(dc *downstreamConn) { uc.forEachDownstream(func(dc *downstreamConn) {
topicWho := dc.marshalUserPrefix(uc.network, ch.TopicWho)
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: xirc.RPL_TOPICWHOTIME, Command: xirc.RPL_TOPICWHOTIME,
Params: []string{ Params: []string{
dc.nick, dc.nick,
dc.marshalEntity(uc.network, ch.Name), dc.marshalEntity(uc.network, ch.Name),
topicWho.String(), ch.TopicWho.String(),
timeStr, timeStr,
}, },
}) })
@ -1551,7 +1550,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
return return
} }
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix), Prefix: msg.Prefix,
Command: "INVITE", Command: "INVITE",
Params: []string{dc.marshalEntity(uc.network, nick), dc.marshalEntity(uc.network, channel)}, Params: []string{dc.marshalEntity(uc.network, nick), dc.marshalEntity(uc.network, channel)},
}) })
@ -1651,11 +1650,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
}) })
case "AWAY", "ACCOUNT": case "AWAY", "ACCOUNT":
uc.forEachDownstream(func(dc *downstreamConn) { uc.forEachDownstream(func(dc *downstreamConn) {
dc.SendMessage(&irc.Message{ dc.SendMessage(msg)
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix),
Command: msg.Command,
Params: msg.Params,
})
}) })
case irc.RPL_BANLIST, irc.RPL_INVITELIST, irc.RPL_EXCEPTLIST: case irc.RPL_BANLIST, irc.RPL_INVITELIST, irc.RPL_EXCEPTLIST:
var channel, mask string var channel, mask string