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.
21 lines
1 KiB
Rust
21 lines
1 KiB
Rust
use crate::engine::db::{human_time, Store};
|
|
use crate::engine::service::{Sender, ServiceCtx};
|
|
|
|
// INFO [account]: show an account's registration details. The email is shown
|
|
// only to the account's own owner.
|
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &dyn Store) {
|
|
let name = args.get(1).copied().unwrap_or(from.nick);
|
|
let Some(acct) = db.account(name) else {
|
|
ctx.notice(me, from.uid, format!("\x02{name}\x02 isn't registered."));
|
|
return;
|
|
};
|
|
ctx.notice(me, from.uid, format!("Information for \x02{}\x02:", acct.name));
|
|
ctx.notice(me, from.uid, format!(" Registered : {}", human_time(acct.ts)));
|
|
if from.account == Some(acct.name.as_str()) {
|
|
match &acct.email {
|
|
Some(email) if acct.verified => ctx.notice(me, from.uid, format!(" Email : {email}")),
|
|
Some(email) => ctx.notice(me, from.uid, format!(" Email : {email} (unconfirmed)")),
|
|
None => ctx.notice(me, from.uid, " Email : (none set)"),
|
|
}
|
|
}
|
|
}
|