Re-enable custom Display for ContactId

Caught another case of using Display instead of ToSql, now all tests
pass again.
This commit is contained in:
Floris Bruynooghe
2022-04-02 15:05:06 +02:00
parent ea0cf67f98
commit 16d201faca
2 changed files with 18 additions and 23 deletions

View File

@@ -15,8 +15,9 @@ use crate::chat::ChatId;
use crate::color::str_to_color;
use crate::config::Config;
use crate::constants::{
Blocked, Chattype, DC_CONTACT_ID_DEVICE, DC_CONTACT_ID_DEVICE_ADDR, DC_CONTACT_ID_LAST_SPECIAL,
DC_CONTACT_ID_SELF, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY,
Blocked, Chattype, DC_CONTACT_ID_DEVICE, DC_CONTACT_ID_DEVICE_ADDR, DC_CONTACT_ID_INFO,
DC_CONTACT_ID_LAST_SPECIAL, DC_CONTACT_ID_SELF, DC_CONTACT_ID_UNDEFINED, DC_GCL_ADD_SELF,
DC_GCL_VERIFIED_ONLY,
};
use crate::context::Context;
use crate::dc_tools::{dc_get_abs_path, improve_single_line_input, EmailAddress};
@@ -52,20 +53,19 @@ impl ContactId {
impl fmt::Display for ContactId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
// if *self == DC_CONTACT_ID_UNDEFINED {
// write!(f, "Contact#Undefined")
// } else if *self == DC_CONTACT_ID_SELF {
// write!(f, "Contact#Self")
// } else if *self == DC_CONTACT_ID_INFO {
// write!(f, "Contact#Info")
// } else if *self == DC_CONTACT_ID_DEVICE {
// write!(f, "Contact#Device")
// } else if *self <= DC_CONTACT_ID_LAST_SPECIAL {
// write!(f, "Contact#Special{}", self.0)
// } else {
// write!(f, "Contact#{}", self.0)
// }
if *self == DC_CONTACT_ID_UNDEFINED {
write!(f, "Contact#Undefined")
} else if *self == DC_CONTACT_ID_SELF {
write!(f, "Contact#Self")
} else if *self == DC_CONTACT_ID_INFO {
write!(f, "Contact#Info")
} else if *self == DC_CONTACT_ID_DEVICE {
write!(f, "Contact#Device")
} else if *self <= DC_CONTACT_ID_LAST_SPECIAL {
write!(f, "Contact#Special{}", self.0)
} else {
write!(f, "Contact#{}", self.0)
}
}
}

View File

@@ -2099,11 +2099,6 @@ async fn check_verified_properties(
if to_ids.is_empty() {
return Ok(());
}
let to_ids_str = to_ids
.iter()
.map(|x| x.to_string())
.collect::<Vec<String>>()
.join(",");
let rows = context
.sql
@@ -2111,9 +2106,9 @@ async fn check_verified_properties(
format!(
"SELECT c.addr, LENGTH(ps.verified_key_fingerprint) FROM contacts c \
LEFT JOIN acpeerstates ps ON c.addr=ps.addr WHERE c.id IN({}) ",
to_ids_str
sql::repeat_vars(to_ids.len())?
),
paramsv![],
rusqlite::params_from_iter(to_ids),
|row| {
let to_addr: String = row.get(0)?;
let is_verified: i32 = row.get(1).unwrap_or(0);