Group the module crates under modules/
The service pseudo-clients and the ircd protocol link sat flat at the repo root, mixed in with the daemon core and the SDK. Move them all under modules/ so the tree separates concerns cleanly: the daemon in src/, the SDK every module links against in api/, and the loadable modules — the pseudo-clients plus the protocol link — in modules/. Workspace members, the daemon's per-crate dependency paths, and each module's api path are updated to match; the docs follow. No code change.
This commit is contained in:
parent
6f76f9722c
commit
ad2a623120
116 changed files with 69 additions and 46 deletions
36
modules/hostserv/src/set.rs
Normal file
36
modules/hostserv/src/set.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use fedserv_api::{parse_duration, NetView, Sender, ServiceCtx, Store};
|
||||
|
||||
// SET <account> <host> [duration]: assign a vhost to an account, applying it at
|
||||
// once to online sessions. An optional duration (e.g. 30d) makes it temporary.
|
||||
// Operators only.
|
||||
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net: &dyn NetView, db: &mut dyn Store) {
|
||||
if !super::require_oper(me, from, ctx) {
|
||||
return;
|
||||
}
|
||||
let (Some(&account), Some(&host)) = (args.get(1), args.get(2)) else {
|
||||
ctx.notice(me, from.uid, "Syntax: SET <account> <host> [duration]");
|
||||
return;
|
||||
};
|
||||
if db.account(account).is_none() {
|
||||
ctx.notice(me, from.uid, format!("\x02{account}\x02 isn't registered."));
|
||||
return;
|
||||
}
|
||||
let host = match super::prepare_vhost(host, account, db) {
|
||||
Ok(h) => h,
|
||||
Err(msg) => {
|
||||
ctx.notice(me, from.uid, msg);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let ttl = args.get(3).and_then(|s| parse_duration(s));
|
||||
match db.set_vhost(account, &host, from.nick, ttl) {
|
||||
Ok(()) => {
|
||||
for uid in net.uids_logged_into(account) {
|
||||
ctx.apply_vhost(&uid, &host);
|
||||
}
|
||||
let when = args.get(3).filter(|_| ttl.is_some()).map(|d| format!(" (expires in {d})")).unwrap_or_default();
|
||||
ctx.notice(me, from.uid, format!("Vhost \x02{host}\x02 assigned to \x02{account}\x02{when}."));
|
||||
}
|
||||
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue