Private
Public Access
1
0

first pass at xpc impl

This commit is contained in:
James Magahern
2025-08-01 12:26:17 -07:00
parent 43b668e9a2
commit 911454aafb
29 changed files with 761 additions and 141 deletions

View File

@@ -50,12 +50,12 @@ impl Conversation {
impl PartialEq for Conversation {
fn eq(&self, other: &Self) -> bool {
self.guid == other.guid &&
self.unread_count == other.unread_count &&
self.display_name == other.display_name &&
self.last_message_preview == other.last_message_preview &&
self.date == other.date &&
self.participants == other.participants
self.guid == other.guid
&& self.unread_count == other.unread_count
&& self.display_name == other.display_name
&& self.last_message_preview == other.last_message_preview
&& self.date == other.date
&& self.participants == other.participants
}
}
@@ -75,7 +75,10 @@ impl From<kordophone::model::Conversation> for Conversation {
participants: value
.participant_display_names
.into_iter()
.map(|p| Participant::Remote { handle: p, contact_id: None }) // todo: this is wrong
.map(|p| Participant::Remote {
handle: p,
contact_id: None,
}) // todo: this is wrong
.collect(),
}
}

View File

@@ -52,7 +52,10 @@ impl From<Record> for Message {
.and_then(|json| serde_json::from_str(&json).ok());
let message_sender = match record.sender_participant_handle {
Some(handle) => Participant::Remote { handle, contact_id: None },
Some(handle) => Participant::Remote {
handle,
contact_id: None,
},
None => Participant::Me,
};
Self {

View File

@@ -22,16 +22,18 @@ pub struct InsertableRecord {
impl From<Participant> for InsertableRecord {
fn from(participant: Participant) -> Self {
match participant {
Participant::Me => InsertableRecord {
handle: "me".to_string(),
is_me: true,
contact_id: None,
},
Participant::Remote { handle, contact_id, .. } => InsertableRecord {
handle,
is_me: false,
contact_id,
},
Participant::Me => InsertableRecord {
handle: "me".to_string(),
is_me: true,
contact_id: None,
},
Participant::Remote {
handle, contact_id, ..
} => InsertableRecord {
handle,
is_me: false,
contact_id,
},
}
}
}
@@ -62,16 +64,18 @@ impl From<Record> for Participant {
impl From<Participant> for Record {
fn from(participant: Participant) -> Self {
match participant {
Participant::Me => Record {
handle: "me".to_string(),
is_me: true,
contact_id: None,
},
Participant::Remote { handle, contact_id, .. } => Record {
handle,
is_me: false,
contact_id,
},
Participant::Me => Record {
handle: "me".to_string(),
is_me: true,
contact_id: None,
},
Participant::Remote {
handle, contact_id, ..
} => Record {
handle,
is_me: false,
contact_id,
},
}
}
}

View File

@@ -28,9 +28,13 @@ impl From<kordophone::model::Message> for Message {
contact_id: None,
// Weird server quirk: some sender handles are encoded with control characters.
handle: sender.chars()
.filter(|c| !c.is_control() && !matches!(c,
'\u{202A}' | // LRE
handle: sender
.chars()
.filter(|c| {
!c.is_control()
&& !matches!(
c,
'\u{202A}' | // LRE
'\u{202B}' | // RLE
'\u{202C}' | // PDF
'\u{202D}' | // LRO
@@ -38,8 +42,9 @@ impl From<kordophone::model::Message> for Message {
'\u{2066}' | // LRI
'\u{2067}' | // RLI
'\u{2068}' | // FSI
'\u{2069}' // PDI
))
'\u{2069}' // PDI
)
})
.collect::<String>(),
},

View File

@@ -5,4 +5,4 @@ pub mod participant;
pub use conversation::Conversation;
pub use message::Message;
pub use participant::Participant;
pub use participant::Participant;

View File

@@ -377,7 +377,11 @@ impl<'a> Repository<'a> {
fn get_or_create_participant(&mut self, participant: &Participant) -> Option<String> {
match participant {
Participant::Me => None,
Participant::Remote { handle: p_handle, contact_id: c_id, .. } => {
Participant::Remote {
handle: p_handle,
contact_id: c_id,
..
} => {
use crate::schema::participants::dsl::*;
let existing_participant = participants