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,12 +2108,11 @@ 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)
}
sendTopic(ctx, dc, ch)
}
case "LIST":
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 {
return err
}
ch, err := uc.getChannel(name)
if err != nil {
return err
}
if msg.Command == irc.RPL_TOPIC {
ch.Topic = topic
ch := uc.channels.Get(name)
if ch == nil {
uc.forwardMsgByID(ctx, downstreamID, msg)
} else {
ch.Topic = ""
if msg.Command == irc.RPL_TOPIC {
ch.Topic = topic
} else {
ch.Topic = ""
}
}
case "TOPIC":
var name string
@ -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