diff --git a/downstream.go b/downstream.go index 3bd74c7..93b8117 100644 --- a/downstream.go +++ b/downstream.go @@ -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) diff --git a/upstream.go b/upstream.go index e506c18..75912c1 100644 --- a/upstream.go +++ b/upstream.go @@ -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