Use self instead of going through services()

This commit is contained in:
Lambda 2024-09-01 11:35:02 +00:00
parent f52cf53931
commit 341f4213d0
8 changed files with 26 additions and 60 deletions

View file

@ -575,10 +575,8 @@ impl Service {
if let Ok(content) =
serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get())
{
if let Some(related_pducount) = services()
.rooms
.timeline
.get_pdu_count(&content.relates_to.event_id)?
if let Some(related_pducount) =
self.get_pdu_count(&content.relates_to.event_id)?
{
services()
.rooms
@ -596,10 +594,8 @@ impl Service {
} => {
// We need to do it again here, because replies don't have
// event_id as a top level field
if let Some(related_pducount) = services()
.rooms
.timeline
.get_pdu_count(&in_reply_to.event_id)?
if let Some(related_pducount) =
self.get_pdu_count(&in_reply_to.event_id)?
{
services().rooms.pdu_metadata.add_relation(
PduCount::Normal(count2),
@ -1134,11 +1130,8 @@ impl Service {
return Ok(None);
}
let pdu_id = services()
.rooms
.timeline
.append_pdu(pdu, pdu_json, new_room_leaves, room_id)
.await?;
let pdu_id =
self.append_pdu(pdu, pdu_json, new_room_leaves, room_id).await?;
Ok(Some(pdu_id))
}
@ -1314,7 +1307,7 @@ impl Service {
.await;
// Skip the PDU if we already have it as a timeline event
if let Some(pdu_id) = services().rooms.timeline.get_pdu_id(&event_id)? {
if let Some(pdu_id) = self.get_pdu_id(&event_id)? {
info!(%event_id, ?pdu_id, "We already know this event");
return Ok(());
}