mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-09 19:13:03 +02:00
feat: Add force-set-latest-extremity command
This commit is contained in:
parent
5cce024841
commit
39023b5ed3
2 changed files with 43 additions and 0 deletions
|
@ -920,3 +920,41 @@ pub(super) async fn trim_memory(&self) -> Result {
|
||||||
|
|
||||||
writeln!(self, "done").await
|
writeln!(self, "done").await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn force_append_latest_extremity(&self, room_id: OwnedRoomId) -> Result {
|
||||||
|
let lock = self.services.rooms.state.mutex.lock(&*room_id).await;
|
||||||
|
let mut extremities: Vec<&EventId> = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.get_forward_extremities(&room_id)
|
||||||
|
.collect()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let latest_pdu = self
|
||||||
|
.services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.latest_pdu_in_room(&room_id)
|
||||||
|
.await
|
||||||
|
.map_err(|_| err!(Database("Failed to find the latest PDU in database")))?;
|
||||||
|
|
||||||
|
let pdu_id = latest_pdu.event_id();
|
||||||
|
if !extremities.contains(&pdu_id) {
|
||||||
|
extremities.push(pdu_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.services
|
||||||
|
.rooms
|
||||||
|
.state
|
||||||
|
.set_forward_extremities(&room_id, extremities.iter().copied(), &lock)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
self.write_str(&format!(
|
||||||
|
"Successfully retained the following {} forward extremities in room \
|
||||||
|
{room_id}:\n```\n{extremities:?}\n```",
|
||||||
|
extremities.len()
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
|
@ -237,6 +237,11 @@ pub enum DebugCommand {
|
||||||
level: Option<i32>,
|
level: Option<i32>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ForceAppendLatestExtremity {
|
||||||
|
/// The room ID
|
||||||
|
room_id: OwnedRoomId,
|
||||||
|
},
|
||||||
|
|
||||||
/// - Developer test stubs
|
/// - Developer test stubs
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue