[client] Polls: a poll is a message, a vote replaces the voter's earlier one, only the asker closes and the close carries the final votes; the client keeps each conversation's polls

This commit is contained in:
2026-11-22 10:37:59 +01:00
parent 056a68de17
commit 65f56e306c
6 changed files with 1024 additions and 10 deletions
+7 -2
View File
@@ -3,8 +3,8 @@
//! keys, fetch tokens and post tokens. `Debug` is not implemented for any of it.
use crate::{
credential_with_key, Client, ClientError, Contact, ContactId, Mailbox, Transport, WelcomeBox,
CIPHERSUITE, MAX_NAME_CHARS,
credential_with_key, Client, ClientError, Contact, ContactId, Mailbox, PollState, Transport,
WelcomeBox, CIPHERSUITE, MAX_NAME_CHARS,
};
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
use base64::Engine as _;
@@ -54,6 +54,9 @@ struct ContactState {
sent_seq: u64,
#[serde(default)]
received_seq: u64,
// F28 (`.agents/features/polls.md` §2.3); absent in older snapshots.
#[serde(default)]
polls: Vec<PollState>,
}
fn yes() -> bool {
@@ -107,6 +110,7 @@ impl<T: Transport> Client<T> {
blocked: c.blocked,
sent_seq: c.sent_seq,
received_seq: c.received_seq,
polls: c.polls.clone(),
})
.collect(),
welcome_boxes: self.welcome_boxes.clone(),
@@ -163,6 +167,7 @@ impl<T: Transport> Client<T> {
blocked: c.blocked,
sent_seq: c.sent_seq,
received_seq: c.received_seq,
polls: c.polls,
});
}
Ok(Client {