mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd95f29ece | |||
| 39023b5ed3 |
@@ -920,3 +920,49 @@ 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,
|
||||||
|
event_id: Option<OwnedEventId>,
|
||||||
|
) -> 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 selected_id = if let Some(event_id) = event_id {
|
||||||
|
event_id
|
||||||
|
} else {
|
||||||
|
self.services
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.latest_pdu_in_room(&room_id)
|
||||||
|
.await
|
||||||
|
.map_err(|_| err!(Database("Failed to find the latest PDU in database")))?
|
||||||
|
.event_id()
|
||||||
|
.to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
|
if !extremities.contains(&selected_id.as_ref()) {
|
||||||
|
extremities.push(&selected_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,16 @@ pub enum DebugCommand {
|
|||||||
level: Option<i32>,
|
level: Option<i32>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// - Forcefully add the latest known event in the specified room as a
|
||||||
|
/// forward extremity. Use with caution.
|
||||||
|
ForceAppendLatestExtremity {
|
||||||
|
/// The room ID
|
||||||
|
room_id: OwnedRoomId,
|
||||||
|
/// If set, forcefully picks an event ID to use as an extremity. Is not
|
||||||
|
/// validated.
|
||||||
|
event_id: Option<OwnedEventId>,
|
||||||
|
},
|
||||||
|
|
||||||
/// - Developer test stubs
|
/// - Developer test stubs
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|||||||
Reference in New Issue
Block a user