Fix unnecessary backfill requests after reaching m.room.create.
Cleanup condition. Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -32,13 +32,18 @@ use super::ExtractBody;
|
|||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
#[tracing::instrument(name = "backfill", level = "debug", skip(self))]
|
#[tracing::instrument(name = "backfill", level = "debug", skip(self))]
|
||||||
pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Result {
|
pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Result {
|
||||||
let first_pdu = self
|
let (first_pdu_count, first_pdu) = self
|
||||||
.first_item_in_room(room_id)
|
.first_item_in_room(room_id)
|
||||||
.await
|
.await
|
||||||
.expect("Room is not empty");
|
.expect("Room is not empty");
|
||||||
|
|
||||||
// No backfill required, there are still events between them
|
// No backfill required, there are still events between them
|
||||||
if first_pdu.0 < from {
|
if first_pdu_count < from {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
// No backfill required, reached the end.
|
||||||
|
if *first_pdu.event_type() == TimelineEventType::RoomCreate {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,13 +82,8 @@ pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Re
|
|||||||
.users
|
.users
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(user_id, level)| {
|
.filter_map(|(user_id, level)| {
|
||||||
if level > &power_levels.users_default
|
(*level > power_levels.users_default && !self.services.globals.user_is_local(user_id))
|
||||||
&& !self.services.globals.user_is_local(user_id)
|
.then_some(user_id.server_name())
|
||||||
{
|
|
||||||
Some(user_id.server_name())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let canonical_room_alias_server = once(canonical_alias)
|
let canonical_room_alias_server = once(canonical_alias)
|
||||||
@@ -118,7 +118,7 @@ pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Re
|
|||||||
while let Some(ref backfill_server) = servers.next().await {
|
while let Some(ref backfill_server) = servers.next().await {
|
||||||
let request = federation::backfill::get_backfill::v1::Request {
|
let request = federation::backfill::get_backfill::v1::Request {
|
||||||
room_id: room_id.to_owned(),
|
room_id: room_id.to_owned(),
|
||||||
v: vec![first_pdu.1.event_id().to_owned()],
|
v: vec![first_pdu.event_id().to_owned()],
|
||||||
limit: uint!(100),
|
limit: uint!(100),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user