darkirc/irc: Fix potential panic when adding nicks to channel nicklists.

This commit is contained in:
parazyd
2023-10-26 10:12:52 +02:00
parent 387897cf7b
commit e9e891db18

View File

@@ -214,9 +214,12 @@ impl Client {
let msg_for_self = *self.nickname.read().await == privmsg.channel;
if have_channel || msg_for_self {
// Add the nickname to the list of nicks on the channel
(*self.server.channels.write().await).get_mut(&privmsg.channel)
.unwrap().nicks.insert(privmsg.nick.clone());
// Add the nickname to the list of nicks on the channel, if it's a channel.
let mut chans_lock = self.server.channels.write().await;
if let Some(chan) = chans_lock.get_mut(&privmsg.channel) {
chan.nicks.insert(privmsg.nick.clone());
}
drop(chans_lock);
// Format the message
let msg = format!("PRIVMSG {} :{}", privmsg.channel, privmsg.msg);