Update downstream caps/nick/realname before sending MOTD

The MOTD indicates the end of the registration's message burst, and
the server can send arbitrary messages before it.

Update the supported capabilities, the nick and the realname before
MOTD to make it so client logic that runs on MOTD can work with
up-to-date info.
This commit is contained in:
Simon Ser 2021-11-17 15:27:34 +01:00
parent 55840312b4
commit 4d3b640989

View File

@ -1187,6 +1187,8 @@ func (dc *downstreamConn) welcome(ctx context.Context) error {
dc.isMultiUpstream = true dc.isMultiUpstream = true
} }
dc.updateSupportedCaps()
isupport := []string{ isupport := []string{
fmt.Sprintf("CHATHISTORY=%v", chatHistoryLimit), fmt.Sprintf("CHATHISTORY=%v", chatHistoryLimit),
"CASEMAPPING=ascii", "CASEMAPPING=ascii",
@ -1249,6 +1251,9 @@ func (dc *downstreamConn) welcome(ctx context.Context) error {
}) })
} }
dc.updateNick()
dc.updateRealname()
if motd := dc.user.srv.Config().MOTD; motd != "" && dc.network == nil { if motd := dc.user.srv.Config().MOTD; motd != "" && dc.network == nil {
for _, msg := range generateMOTD(dc.srv.prefix(), dc.nick, motd) { for _, msg := range generateMOTD(dc.srv.prefix(), dc.nick, motd) {
dc.SendMessage(msg) dc.SendMessage(msg)
@ -1265,10 +1270,6 @@ func (dc *downstreamConn) welcome(ctx context.Context) error {
}) })
} }
dc.updateNick()
dc.updateRealname()
dc.updateSupportedCaps()
if dc.caps["soju.im/bouncer-networks-notify"] { if dc.caps["soju.im/bouncer-networks-notify"] {
dc.SendBatch("soju.im/bouncer-networks", nil, nil, func(batchRef irc.TagValue) { dc.SendBatch("soju.im/bouncer-networks", nil, nil, func(batchRef irc.TagValue) {
dc.user.forEachNetwork(func(network *network) { dc.user.forEachNetwork(func(network *network) {