diff --git a/src/modules/chanlog.rs b/src/modules/chanlog.rs index baa3f74..673d201 100644 --- a/src/modules/chanlog.rs +++ b/src/modules/chanlog.rs @@ -3,7 +3,6 @@ //! `chanlog = #channel` is configured. use crate::server::Server; -use crate::Uid; /// Tee `msg` to the configured chanlog channel (if set and it exists). Called at /// the tail of `Server::snotice`. Read-only over server state, so it can't loop. @@ -11,12 +10,12 @@ pub fn tee(s: &Server, msg: &str) { let Some(chan) = s.conf("chanlog") else { return; }; - let Some(ch) = s.channels.get(&chan.to_ascii_lowercase()) else { + let key = chan.to_ascii_lowercase(); + if !s.channels.contains_key(&key) { return; // channel not created yet — nothing to log into - }; - let line = format!(":{} NOTICE {chan} :{msg}", s.name); - let members: Vec = ch.members.keys().copied().collect(); - for u in members { - s.send(u, line.clone()); } + // to_channel builds the line once and shares it by Arc across members (and adds + // the server-time tag per recipient) instead of cloning a String per member. + let line = format!(":{} NOTICE {chan} :{msg}", s.name); + s.to_channel(&key, &line, None); }