mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
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:
@@ -15,8 +15,9 @@ use crate::chat::ChatId;
|
|||||||
use crate::color::str_to_color;
|
use crate::color::str_to_color;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{
|
use crate::constants::{
|
||||||
Blocked, Chattype, DC_CONTACT_ID_DEVICE, DC_CONTACT_ID_DEVICE_ADDR, DC_CONTACT_ID_LAST_SPECIAL,
|
Blocked, Chattype, DC_CONTACT_ID_DEVICE, DC_CONTACT_ID_DEVICE_ADDR, DC_CONTACT_ID_INFO,
|
||||||
DC_CONTACT_ID_SELF, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY,
|
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::context::Context;
|
||||||
use crate::dc_tools::{dc_get_abs_path, improve_single_line_input, EmailAddress};
|
use crate::dc_tools::{dc_get_abs_path, improve_single_line_input, EmailAddress};
|
||||||
@@ -52,20 +53,19 @@ impl ContactId {
|
|||||||
|
|
||||||
impl fmt::Display for ContactId {
|
impl fmt::Display for ContactId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
if *self == DC_CONTACT_ID_UNDEFINED {
|
||||||
// if *self == DC_CONTACT_ID_UNDEFINED {
|
write!(f, "Contact#Undefined")
|
||||||
// write!(f, "Contact#Undefined")
|
} else if *self == DC_CONTACT_ID_SELF {
|
||||||
// } else if *self == DC_CONTACT_ID_SELF {
|
write!(f, "Contact#Self")
|
||||||
// write!(f, "Contact#Self")
|
} else if *self == DC_CONTACT_ID_INFO {
|
||||||
// } else if *self == DC_CONTACT_ID_INFO {
|
write!(f, "Contact#Info")
|
||||||
// write!(f, "Contact#Info")
|
} else if *self == DC_CONTACT_ID_DEVICE {
|
||||||
// } else if *self == DC_CONTACT_ID_DEVICE {
|
write!(f, "Contact#Device")
|
||||||
// write!(f, "Contact#Device")
|
} else if *self <= DC_CONTACT_ID_LAST_SPECIAL {
|
||||||
// } else if *self <= DC_CONTACT_ID_LAST_SPECIAL {
|
write!(f, "Contact#Special{}", self.0)
|
||||||
// write!(f, "Contact#Special{}", self.0)
|
} else {
|
||||||
// } else {
|
write!(f, "Contact#{}", self.0)
|
||||||
// write!(f, "Contact#{}", self.0)
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2099,11 +2099,6 @@ async fn check_verified_properties(
|
|||||||
if to_ids.is_empty() {
|
if to_ids.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let to_ids_str = to_ids
|
|
||||||
.iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join(",");
|
|
||||||
|
|
||||||
let rows = context
|
let rows = context
|
||||||
.sql
|
.sql
|
||||||
@@ -2111,9 +2106,9 @@ async fn check_verified_properties(
|
|||||||
format!(
|
format!(
|
||||||
"SELECT c.addr, LENGTH(ps.verified_key_fingerprint) FROM contacts c \
|
"SELECT c.addr, LENGTH(ps.verified_key_fingerprint) FROM contacts c \
|
||||||
LEFT JOIN acpeerstates ps ON c.addr=ps.addr WHERE c.id IN({}) ",
|
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| {
|
|row| {
|
||||||
let to_addr: String = row.get(0)?;
|
let to_addr: String = row.get(0)?;
|
||||||
let is_verified: i32 = row.get(1).unwrap_or(0);
|
let is_verified: i32 = row.get(1).unwrap_or(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user