services(timeline): use `self` instead of `services()`

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-06-07 03:52:37 -04:00
parent 14ec41c211
commit c0c7f23a05
1 changed files with 5 additions and 15 deletions

View File

@ -494,11 +494,7 @@ impl Service {
} }
if let Ok(content) = serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get()) { if let Ok(content) = serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get()) {
if let Some(related_pducount) = services() if let Some(related_pducount) = self.get_pdu_count(&content.relates_to.event_id)? {
.rooms
.timeline
.get_pdu_count(&content.relates_to.event_id)?
{
services() services()
.rooms .rooms
.pdu_metadata .pdu_metadata
@ -513,11 +509,7 @@ impl Service {
} => { } => {
// We need to do it again here, because replies don't have // We need to do it again here, because replies don't have
// event_id as a top level field // event_id as a top level field
if let Some(related_pducount) = services() if let Some(related_pducount) = self.get_pdu_count(&in_reply_to.event_id)? {
.rooms
.timeline
.get_pdu_count(&in_reply_to.event_id)?
{
services() services()
.rooms .rooms
.pdu_metadata .pdu_metadata
@ -646,7 +638,7 @@ impl Service {
// Our depth is the maximum depth of prev_events + 1 // Our depth is the maximum depth of prev_events + 1
let depth = prev_events let depth = prev_events
.iter() .iter()
.filter_map(|event_id| Some(services().rooms.timeline.get_pdu(event_id).ok()??.depth)) .filter_map(|event_id| Some(self.get_pdu(event_id).ok()??.depth))
.max() .max()
.unwrap_or_else(|| uint!(0)) .unwrap_or_else(|| uint!(0))
+ uint!(1); + uint!(1);
@ -945,9 +937,7 @@ impl Service {
return Ok(None); return Ok(None);
} }
let pdu_id = services() let pdu_id = self
.rooms
.timeline
.append_pdu(pdu, pdu_json, new_room_leaves, state_lock) .append_pdu(pdu, pdu_json, new_room_leaves, state_lock)
.await?; .await?;
@ -1138,7 +1128,7 @@ impl Service {
let mutex_lock = mutex.lock().await; let mutex_lock = mutex.lock().await;
// Skip the PDU if we already have it as a timeline event // 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!("We already know {event_id} at {pdu_id:?}"); info!("We already know {event_id} at {pdu_id:?}");
return Ok(()); return Ok(());
} }