Rebrand the daemon and workspace: the binary is now `echo`, every crate is `echo-*` (`echo-api` and the module crates), Rust imports use `echo_*`, the gRPC proto is `proto/echo.proto` with package `echo.v1`, and the log filter, gossip peer-name default, and on-disk store default (`echo.db.jsonl`) follow. Docs updated throughout. No behaviour change; crate directories and the config schema are untouched.
33 lines
1.3 KiB
Rust
33 lines
1.3 KiB
Rust
use echo_api::{Sender, ServiceCtx, Store};
|
|
|
|
// REQUEST <host>: ask for a vhost, to be approved by an operator.
|
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
|
let Some(account) = from.account else {
|
|
ctx.notice(me, from.uid, "You need to identify to NickServ first.");
|
|
return;
|
|
};
|
|
let Some(&host) = args.get(1) else {
|
|
ctx.notice(me, from.uid, "Syntax: REQUEST <host>");
|
|
return;
|
|
};
|
|
let host = match super::prepare_vhost(host, account, db) {
|
|
Ok(h) => h,
|
|
Err(msg) => {
|
|
ctx.notice(me, from.uid, msg);
|
|
return;
|
|
}
|
|
};
|
|
if db.vhost_is_forbidden(&host) {
|
|
ctx.notice(me, from.uid, format!("\x02{host}\x02 isn't allowed here. Please choose another."));
|
|
return;
|
|
}
|
|
let wait = db.vhost_request_wait(account);
|
|
if wait > 0 {
|
|
ctx.notice(me, from.uid, format!("Please wait \x02{wait}\x02s before requesting another vhost."));
|
|
return;
|
|
}
|
|
match db.request_vhost(account, &host) {
|
|
Ok(()) => ctx.notice(me, from.uid, format!("Requested vhost \x02{host}\x02 — an operator will review it.")),
|
|
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
|
}
|
|
}
|