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

View File

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