Pass MODE and TOPIC through for unjoined channels

This commit is contained in:
Eric Mertens 2023-08-22 11:36:28 -07:00 committed by Simon Ser
parent 33a83b3b41
commit 3650446156
2 changed files with 27 additions and 25 deletions

View File

@ -2060,10 +2060,9 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
} else { } else {
ch := uc.channels.Get(name) ch := uc.channels.Get(name)
if ch == nil { if ch == nil {
return ircError{&irc.Message{ // we're not on that channel, pass command to upstream
Command: irc.ERR_NOSUCHCHANNEL, uc.SendMessageLabeled(ctx, dc.id, msg)
Params: []string{dc.nick, name, "No such channel"}, return nil
}}
} }
if ch.modes == nil { if ch.modes == nil {
@ -2109,12 +2108,11 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
} else { // getting topic } else { // getting topic
ch := uc.channels.Get(name) ch := uc.channels.Get(name)
if ch == nil { if ch == nil {
return ircError{&irc.Message{ // we're not on that channel, pass command to upstream
Command: irc.ERR_NOSUCHCHANNEL, uc.SendMessageLabeled(ctx, dc.id, msg)
Params: []string{dc.nick, name, "No such channel"}, } else {
}} sendTopic(ctx, dc, ch)
} }
sendTopic(ctx, dc, ch)
} }
case "LIST": case "LIST":
uc, err := dc.upstreamForCommand(msg.Command) uc, err := dc.upstreamForCommand(msg.Command)

View File

@ -1282,14 +1282,15 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
if err := parseMessageParams(msg, nil, &name, &topic); err != nil { if err := parseMessageParams(msg, nil, &name, &topic); err != nil {
return err return err
} }
ch, err := uc.getChannel(name) ch := uc.channels.Get(name)
if err != nil { if ch == nil {
return err uc.forwardMsgByID(ctx, downstreamID, msg)
}
if msg.Command == irc.RPL_TOPIC {
ch.Topic = topic
} else { } else {
ch.Topic = "" if msg.Command == irc.RPL_TOPIC {
ch.Topic = topic
} else {
ch.Topic = ""
}
} }
case "TOPIC": case "TOPIC":
var name string var name string
@ -1367,9 +1368,10 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
modeStr = msg.Params[2] modeStr = msg.Params[2]
} }
ch, err := uc.getChannel(channel) ch := uc.channels.Get(channel)
if err != nil { if ch == nil {
return err uc.forwardMsgByID(ctx, downstreamID, msg)
return nil
} }
firstMode := ch.modes == nil firstMode := ch.modes == nil
@ -1388,9 +1390,10 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
return err return err
} }
ch, err := uc.getChannel(channel) ch := uc.channels.Get(channel)
if err != nil { if ch == nil {
return err uc.forwardMsgByID(ctx, downstreamID, msg)
return nil
} }
firstCreationTime := ch.creationTime == "" firstCreationTime := ch.creationTime == ""
@ -1406,9 +1409,10 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
return err return err
} }
ch, err := uc.getChannel(channel) ch := uc.channels.Get(channel)
if err != nil { if ch == nil {
return err uc.forwardMsgByID(ctx, downstreamID, msg)
return nil
} }
firstTopicWhoTime := ch.TopicWho == nil firstTopicWhoTime := ch.TopicWho == nil