move metadata out of core into its own module file

This commit is contained in:
Jean Chevronnet 2026-08-08 22:44:58 +00:00
parent ee98fade40
commit 50a95c6686
4 changed files with 213 additions and 164 deletions

View file

@ -165,10 +165,9 @@ pub struct Server {
pub label_capture: RefCell<Option<(Uid, Vec<String>)>>,
pub history: HashMap<String, VecDeque<HistMsg>>, // channel key -> recent messages (CHATHISTORY)
pub read_markers: HashMap<String, HashMap<String, u64>>, // identity -> target -> read ts (MARKREAD)
pub metadata: HashMap<String, HashMap<String, String>>, // target key -> key -> value (draft/metadata-2)
pub mline: HashMap<Uid, MlineBatch>, // in-progress inbound multiline batches
pub event_tx: Sender<Event>, // self-inject events (DNS results)
pub conn_counter: Arc<AtomicU64>, // mints connection uids (for CONNECT dials)
pub mline: HashMap<Uid, MlineBatch>, // in-progress inbound multiline batches
pub event_tx: Sender<Event>, // self-inject events (DNS results)
pub conn_counter: Arc<AtomicU64>, // mints connection uids (for CONNECT dials)
/// Module-owned server state, keyed by type — the InspIRCd `ExtensionItem`
/// equivalent. Each `modules/*.rs` stores its own struct here so features live
/// in their own file instead of bloating this one.
@ -216,7 +215,6 @@ impl Server {
label_capture: RefCell::new(None),
history: HashMap::new(),
read_markers: HashMap::new(),
metadata: HashMap::new(),
mline: HashMap::new(),
event_tx,
conn_counter,
@ -331,18 +329,6 @@ impl Server {
Some((mb.target, mb.notice, lines))
}
/// Resolve a METADATA target (a nick or `#channel`) to its metadata storage
/// key, or `None` if it doesn't exist. User keys are `u<uid>` (stable across
/// nick changes); channel keys are the lowercased name.
pub fn meta_key(&self, target: &str) -> Option<String> {
if let Some(chan) = target.strip_prefix('#') {
let k = format!("#{}", chan.to_ascii_lowercase());
self.channels.contains_key(&k).then_some(k)
} else {
self.find_nick(target).map(|u| format!("u{u}"))
}
}
/// The read-marker identity for `uid`: their account when logged in (so markers
/// are shared across their devices and survive reconnects), else a per-session
/// key. `remove_user` prunes the session key on disconnect.
@ -531,7 +517,6 @@ impl Server {
};
self.uuid_local.remove(&user.uuid);
self.read_markers.remove(&format!("~{uid}")); // session read-markers (kept if account-keyed)
self.metadata.remove(&format!("u{uid}")); // per-user metadata
self.mline.remove(&uid); // any half-open multiline batch
if user.registered {
self.push_whowas(