Abstract Pdu filter matching into trait Event.

Abstract Pdu unsigned accessors into trait Event.

Abstract Pdu relation related into trait Event.

Abstract PDU content into trait Event.

Move event_id utils from pdu to event.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-04-27 09:34:07 +00:00
parent 222e89f6fe
commit af7dfb31bc
56 changed files with 666 additions and 492 deletions

View File

@@ -49,10 +49,9 @@ impl crate::Service for Service {
}
impl Service {
pub async fn add_to_thread<'a, E>(&self, root_event_id: &EventId, event: &'a E) -> Result
pub async fn add_to_thread<E>(&self, root_event_id: &EventId, event: &E) -> Result
where
E: Event + Send + Sync,
&'a E: Event + Send,
{
let root_id = self
.services
@@ -120,7 +119,7 @@ impl Service {
self.services
.timeline
.replace_pdu(&root_id, &root_pdu_json, &root_pdu)
.replace_pdu(&root_id, &root_pdu_json)
.await?;
}
@@ -130,7 +129,7 @@ impl Service {
users.extend_from_slice(&userids);
},
| _ => {
users.push(root_pdu.sender);
users.push(root_pdu.sender().to_owned());
},
}
users.push(event.sender().to_owned());
@@ -171,10 +170,10 @@ impl Service {
.get_pdu_from_id(&pdu_id)
.await
.ok()?;
let pdu_id: PduId = pdu_id.into();
if pdu.sender != user_id {
pdu.remove_transaction_id().ok();
let pdu_id: PduId = pdu_id.into();
if pdu.sender() != user_id {
pdu.as_mut_pdu().remove_transaction_id().ok();
}
Some((pdu_id.shorteventid, pdu))