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
26
modules/memoserv/src/list.rs
Normal file
26
modules/memoserv/src/list.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use fedserv_api::{human_time, Sender, ServiceCtx, Store};
|
||||
|
||||
// LIST: show every memo with a one-line preview; \x02*\x02 marks unread.
|
||||
pub fn handle(me: &str, from: &Sender, account: &str, ctx: &mut ServiceCtx, db: &dyn Store) {
|
||||
let memos = db.memo_list(account);
|
||||
if memos.is_empty() {
|
||||
ctx.notice(me, from.uid, "You have no memos.");
|
||||
return;
|
||||
}
|
||||
let unread = memos.iter().filter(|m| !m.read).count();
|
||||
ctx.notice(me, from.uid, format!("Your memos ({} total, {unread} new). \x02*\x02 marks unread:", memos.len()));
|
||||
for (i, m) in memos.iter().enumerate() {
|
||||
let flag = if m.read { ' ' } else { '*' };
|
||||
ctx.notice(me, from.uid, format!(" {}{flag} from \x02{}\x02 ({}): {}", i + 1, m.from, human_time(m.ts), preview(&m.text)));
|
||||
}
|
||||
}
|
||||
|
||||
// First line / first 80 chars, for LIST.
|
||||
fn preview(text: &str) -> String {
|
||||
let line = text.lines().next().unwrap_or("");
|
||||
if line.chars().count() > 80 {
|
||||
format!("{}…", line.chars().take(80).collect::<String>())
|
||||
} else {
|
||||
line.to_string()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue