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

@@ -9,8 +9,11 @@ use crate::daemon::{
settings::Settings,
signals::Signal,
DaemonResult,
contact_resolver::{ContactResolver, EDSContactResolverBackend},
};
use kordophone_db::models::participant::Participant;
use crate::dbus::endpoint::DbusRegistry;
use crate::dbus::interface;
use crate::dbus::interface::signals as DbusSignals;
@@ -167,6 +170,24 @@ impl DBusAgent {
.unwrap()
.map_err(|e| MethodErr::failed(&format!("Daemon error: {}", e)))
}
fn resolve_participant_display_name(&self, participant: &Participant) -> String {
let resolver = ContactResolver::new(EDSContactResolverBackend::default());
match participant {
// Me (we should use a special string here...)
Participant::Me => "(Me)".to_string(),
// Remote participant with a resolved contact_id
Participant::Remote { display_name, contact_id: Some(contact_id), .. } => {
resolver.get_contact_display_name(contact_id).unwrap_or_else(|| display_name.clone())
}
// Remote participant without a resolved contact_id
Participant::Remote { display_name, .. } => {
display_name.clone()
}
}
}
}
//
@@ -207,7 +228,7 @@ impl DbusRepository for DBusAgent {
arg::Variant(Box::new(
conv.participants
.into_iter()
.map(|p| p.display_name())
.map(|p| self.resolve_participant_display_name(&p))
.collect::<Vec<String>>(),
)),
);
@@ -221,6 +242,7 @@ impl DbusRepository for DBusAgent {
})
}
fn sync_conversation_list(&mut self) -> Result<(), MethodErr> {
self.send_event_sync(Event::SyncConversationList)
}