//! Who is in a chat, and who of them a database does not hold as a person.//!//! A member is matched by a phone or a handle, never by a name — two people//! called Ravi are not one person. A member with no phone and no handle (a seat//! a source gave only a name) cannot be matched to anyone, so they are an//! outsider too, named by the name the chat shows. Moving a chat into a shared//! database is refused while any member is an outsider there//! (`cotton_tools::messages::admission`).//!//! Pure, like its neighbours: the members and the database's people arrive as//! arguments.use std::collections::BTreeMap;usesuper::resolve_contact::{ handle_key, normalize_contact_handle, ContactHandleKind, MatchedPerson,};/// One member of a chat other than the owner: the name the chat shows them/// by, and every way they are reached, as the rows hold it — `(kind, value)`/// with the kind a handle row's own word (`phone`, `email`, `instagram`, …).#[derive(Debug, Clone, PartialEq, Eq)]pubstructChatMember {pub name: String,pub handles: Vec<(String, String)>,}/// The members who are NOT people in the database, by name, in the chat's own/// order and each once.////// `people` is the database's own people by handle/// ([`super::resolve_contact::people_by_handle`]): archived people are not in/// it, and a handle two people both carry reaches neither — a member matched/// to the wrong person would be let in under somebody else's name.pubfn outsiders(members: &[ChatMember], people: &BTreeMap<String, MatchedPerson>) -> Vec<String> {letmut names: Vec<String> = Vec::new();for member in members {let known = member.handles.iter().any(|(kind, value)| {ContactHandleKind::parse(kind) .and_then(|kind| normalize_contact_handle(kind, value)) .is_some_and(|handle| people.contains_key(&handle_key(&handle))) });if !known && !names.contains(&member.name) { names.push(member.name.clone()); } } names}#[cfg(test)]#[path = "members_tests.rs"]mod tests;