Services no longer receive the concrete account store. on_command now takes &mut dyn Store + &dyn NetView (both defined in fedserv-api); the engine's Db and Network implement them. Reads hand back plain views (AccountView, ChannelView, ...) carrying only non-secret fields, so the event log, gossip, and credential material (password hash, SCRAM verifiers) are unreachable from a module. All command modules ported; behaviour unchanged.
28 lines
1.1 KiB
Rust
28 lines
1.1 KiB
Rust
use crate::engine::db::Store;
|
|
use crate::engine::service::{Sender, ServiceCtx};
|
|
|
|
// MODE <#channel> <modes>: the founder sets channel modes via ChanServ.
|
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
|
let Some(&chan) = args.get(1) else {
|
|
ctx.notice(me, from.uid, "Syntax: MODE <#channel> <modes>, e.g. MODE #chan +nt");
|
|
return;
|
|
};
|
|
if args.len() <= 2 {
|
|
ctx.notice(me, from.uid, "Syntax: MODE <#channel> <modes>, e.g. MODE #chan +nt");
|
|
return;
|
|
}
|
|
let founder = match db.channel(chan) {
|
|
Some(info) => info.founder.clone(),
|
|
None => {
|
|
ctx.notice(me, from.uid, format!("\x02{chan}\x02 isn't registered."));
|
|
return;
|
|
}
|
|
};
|
|
if from.account != Some(founder.as_str()) {
|
|
ctx.notice(me, from.uid, format!("Only \x02{chan}\x02's founder can change its modes."));
|
|
return;
|
|
}
|
|
let modes = args[2..].join(" ");
|
|
ctx.channel_mode(me, chan, &modes);
|
|
ctx.notice(me, from.uid, format!("Set \x02{modes}\x02 on \x02{chan}\x02."));
|
|
}
|