Handle downstream JOIN/PART with multiple channel names
Closes: https://todo.sr.ht/~emersion/soju/19
This commit is contained in:
parent
21241c2009
commit
146906ef6b
@ -833,35 +833,37 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
uc.SendMessage(msg)
|
uc.SendMessage(msg)
|
||||||
})
|
})
|
||||||
case "JOIN", "PART":
|
case "JOIN", "PART":
|
||||||
var name string
|
var names string
|
||||||
if err := parseMessageParams(msg, &name); err != nil {
|
if err := parseMessageParams(msg, &names); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
uc, upstreamName, err := dc.unmarshalEntity(name)
|
for _, name := range strings.Split(names, ",") {
|
||||||
if err != nil {
|
uc, upstreamName, err := dc.unmarshalEntity(name)
|
||||||
return ircError{&irc.Message{
|
|
||||||
Command: irc.ERR_NOSUCHCHANNEL,
|
|
||||||
Params: []string{name, err.Error()},
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
uc.SendMessage(&irc.Message{
|
|
||||||
Command: msg.Command,
|
|
||||||
Params: []string{upstreamName},
|
|
||||||
})
|
|
||||||
|
|
||||||
switch msg.Command {
|
|
||||||
case "JOIN":
|
|
||||||
err := dc.srv.db.StoreChannel(uc.network.ID, &Channel{
|
|
||||||
Name: upstreamName,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dc.logger.Printf("failed to create channel %q in DB: %v", upstreamName, err)
|
return ircError{&irc.Message{
|
||||||
|
Command: irc.ERR_NOSUCHCHANNEL,
|
||||||
|
Params: []string{name, err.Error()},
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
case "PART":
|
|
||||||
if err := dc.srv.db.DeleteChannel(uc.network.ID, upstreamName); err != nil {
|
uc.SendMessage(&irc.Message{
|
||||||
dc.logger.Printf("failed to delete channel %q in DB: %v", upstreamName, err)
|
Command: msg.Command,
|
||||||
|
Params: []string{upstreamName},
|
||||||
|
})
|
||||||
|
|
||||||
|
switch msg.Command {
|
||||||
|
case "JOIN":
|
||||||
|
err := dc.srv.db.StoreChannel(uc.network.ID, &Channel{
|
||||||
|
Name: upstreamName,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
dc.logger.Printf("failed to create channel %q in DB: %v", upstreamName, err)
|
||||||
|
}
|
||||||
|
case "PART":
|
||||||
|
if err := dc.srv.db.DeleteChannel(uc.network.ID, upstreamName); err != nil {
|
||||||
|
dc.logger.Printf("failed to delete channel %q in DB: %v", upstreamName, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "MODE":
|
case "MODE":
|
||||||
|
Loading…
Reference in New Issue
Block a user