Private
Public Access
1
0

Don't overwrite already resolved participants, better naming of keys

This commit is contained in:
2025-06-26 18:23:15 -07:00
parent bb19db17cd
commit f6bb1a9b57
25 changed files with 263 additions and 306 deletions

View File

@@ -23,6 +23,7 @@ use dbus_tokio::connection;
pub struct DBusAgent {
event_sink: mpsc::Sender<Event>,
signal_receiver: Arc<Mutex<Option<mpsc::Receiver<Signal>>>>,
contact_resolver: ContactResolver<EDSContactResolverBackend>,
}
impl DBusAgent {
@@ -30,6 +31,7 @@ impl DBusAgent {
Self {
event_sink,
signal_receiver: Arc::new(Mutex::new(Some(signal_receiver))),
contact_resolver: ContactResolver::new(EDSContactResolverBackend::default()),
}
}
@@ -172,19 +174,18 @@ impl DBusAgent {
}
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())
Participant::Remote { handle, contact_id: Some(contact_id), .. } => {
self.contact_resolver.get_contact_display_name(contact_id).unwrap_or_else(|| handle.clone())
}
// Remote participant without a resolved contact_id
Participant::Remote { display_name, .. } => {
display_name.clone()
Participant::Remote { handle, .. } => {
handle.clone()
}
}
}
@@ -278,6 +279,8 @@ impl DbusRepository for DBusAgent {
// Remove the attachment placeholder here.
let text = msg.text.replace("\u{FFFC}", "");
log::debug!("sender: {:?}", msg.sender.clone());
map.insert("text".into(), arg::Variant(Box::new(text)));
map.insert(
"date".into(),
@@ -285,9 +288,11 @@ impl DbusRepository for DBusAgent {
);
map.insert(
"sender".into(),
arg::Variant(Box::new(msg.sender.display_name())),
arg::Variant(Box::new(self.resolve_participant_display_name(&msg.sender.into()))),
);
// Attachments array
let attachments: Vec<arg::PropMap> = msg
.attachments