Private
Public Access
1
0

Started working on contact resolution

This commit is contained in:
2025-06-26 16:23:53 -07:00
parent 3b30cb77c8
commit bb19db17cd
14 changed files with 405 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ pub struct Record {
pub id: i32,
pub display_name: Option<String>,
pub is_me: bool,
pub contact_id: Option<String>,
}
#[derive(Insertable)]
@@ -15,19 +16,22 @@ pub struct Record {
pub struct InsertableRecord {
pub display_name: Option<String>,
pub is_me: bool,
pub contact_id: Option<String>,
}
impl From<Participant> for InsertableRecord {
fn from(participant: Participant) -> Self {
match participant {
Participant::Me => InsertableRecord {
display_name: None,
is_me: true,
},
Participant::Remote { display_name, .. } => InsertableRecord {
display_name: Some(display_name),
is_me: false,
},
Participant::Me => InsertableRecord {
display_name: None,
is_me: true,
contact_id: None,
},
Participant::Remote { display_name, contact_id, .. } => InsertableRecord {
display_name: Some(display_name),
is_me: false,
contact_id,
},
}
}
}
@@ -50,6 +54,7 @@ impl From<Record> for Participant {
Participant::Remote {
id: Some(record.id),
display_name: record.display_name.unwrap_or_default(),
contact_id: record.contact_id,
}
}
}
@@ -58,16 +63,18 @@ impl From<Record> for Participant {
impl From<Participant> for Record {
fn from(participant: Participant) -> Self {
match participant {
Participant::Me => Record {
id: 0, // This will be set by the database
display_name: None,
is_me: true,
},
Participant::Remote { display_name, .. } => Record {
id: 0, // This will be set by the database
display_name: Some(display_name),
is_me: false,
},
Participant::Me => Record {
id: 0, // This will be set by the database
display_name: None,
is_me: true,
contact_id: None,
},
Participant::Remote { display_name, contact_id, .. } => Record {
id: 0, // This will be set by the database
display_name: Some(display_name),
is_me: false,
contact_id,
},
}
}
}

View File

@@ -29,6 +29,7 @@ impl From<kordophone::model::Message> for Message {
Some(sender) => Participant::Remote {
id: None,
display_name: sender,
contact_id: None,
},
None => Participant::Me,
},

View File

@@ -4,6 +4,7 @@ pub enum Participant {
Remote {
id: Option<i32>,
display_name: String,
contact_id: Option<String>,
},
}
@@ -12,6 +13,7 @@ impl From<String> for Participant {
Participant::Remote {
id: None,
display_name,
contact_id: None,
}
}
}
@@ -21,6 +23,7 @@ impl From<&str> for Participant {
Participant::Remote {
id: None,
display_name: display_name.to_string(),
contact_id: None,
}
}
}