fix: serialize contact history entries as objects across the FFI
This commit is contained in:
parent
aa8c7ec71a
commit
d7179694a6
1 changed files with 11 additions and 2 deletions
|
|
@ -887,12 +887,21 @@ pub extern "C" fn smol_contact(store: *mut Store, address: *const c_char) -> *mu
|
||||||
let address = text(address)?;
|
let address = text(address)?;
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
// History entries serialize as objects, matching smol_contacts and
|
||||||
|
// the facade's parser — a bare tuple would cross the FFI as a JSON
|
||||||
|
// array and break the first contact that ever gains rotation history.
|
||||||
|
struct History {
|
||||||
|
key: String,
|
||||||
|
until: i64,
|
||||||
|
}
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
struct Out {
|
struct Out {
|
||||||
key: String,
|
key: String,
|
||||||
verified: bool,
|
verified: bool,
|
||||||
active: Option<bool>,
|
active: Option<bool>,
|
||||||
accepted_key: Option<String>,
|
accepted_key: Option<String>,
|
||||||
history: Vec<(String, i64)>,
|
history: Vec<History>,
|
||||||
}
|
}
|
||||||
let Some((key, verified)) = store.contact(address)? else {
|
let Some((key, verified)) = store.contact(address)? else {
|
||||||
return Ok(ser(&Out {
|
return Ok(ser(&Out {
|
||||||
|
|
@ -913,7 +922,7 @@ pub extern "C" fn smol_contact(store: *mut Store, address: *const c_char) -> *mu
|
||||||
history: store
|
history: store
|
||||||
.history(address)?
|
.history(address)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(key, until)| (b32(&key), until))
|
.map(|(key, until)| History { key: b32(&key), until })
|
||||||
.collect(),
|
.collect(),
|
||||||
})?)
|
})?)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue