spaces: leaving a room says so, so an owner stops publishing a seat nobody sits in

This commit is contained in:
KeelrLeek committed 2026-09-04 09:56:39 -05:00
1 parent d6102101af
commit 06baa5a805
3 files changed
+147 -7

No files matched your search

+21
View File
@@ -54,6 +54,7 @@ pub enum Cargo {
SpaceKey(SpaceKeyCargo),
ProposalPing(ProposalPing),
SpaceJoin(SpaceJoin),
SpaceLeave(SpaceLeave),
}
/// The answer to an invitation: "here is the key I will wear in your Space."
@@ -68,6 +69,18 @@ pub struct SpaceJoin {
pub proof: Vec<u8>,
}
/// "I am giving up my seat." The owner cannot see a member walk away — the
/// roster is theirs to publish — so leaving says so, sealed. `worn` is the key
/// on the roster, and `proof` is signed BY that key: holding the seat is the
/// whole authority to vacate it.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SpaceLeave {
pub space_id: [u8; 16],
pub owner: [u8; 32],
pub worn: [u8; 32],
pub proof: Vec<u8>,
}
/// "Someone put a proposal on your playlist's board." Carries only enough to
/// name it in a toast — the board itself stays the truth, and this is a
/// best-effort nudge: the proposal stands whether or not the ping lands.
@@ -507,6 +520,7 @@ async fn dispatch(app: &tauri::AppHandle, sender: [u8; 32], cargo: Cargo) {
Cargo::SpaceKey(k) => crate::spaces::on_inbox_space_key(app, sender, k).await,
Cargo::ProposalPing(p) => crate::proposals::on_inbox_proposal(app, sender, p),
Cargo::SpaceJoin(j) => crate::spaces::on_inbox_join(app, sender, j).await,
Cargo::SpaceLeave(l) => crate::spaces::on_inbox_leave(app, sender, l).await,
}
}
@@ -572,8 +586,15 @@ mod tests {
room_key: [10u8; 32],
proof: vec![1, 2, 3],
});
let leave = Cargo::SpaceLeave(SpaceLeave {
space_id: [11u8; 16],
owner: [12u8; 32],
worn: [13u8; 32],
proof: vec![4, 5, 6],
});
assert_eq!(index(&ping), 6, "a new variant must be appended, never inserted");
assert_eq!(index(&join), 7, "a new variant must be appended, never inserted");
assert_eq!(index(&leave), 8, "a new variant must be appended, never inserted");
let back: Cargo = bincode::deserialize(&bincode::serialize(&ping).unwrap()).unwrap();
match back {