mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-09 14:33:03 +02:00
feat: Allow manually specifying event IDs as extremities
This commit is contained in:
parent
39023b5ed3
commit
cd95f29ece
2 changed files with 24 additions and 11 deletions
|
@ -922,7 +922,11 @@ pub(super) async fn trim_memory(&self) -> Result {
|
|||
}
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn force_append_latest_extremity(&self, room_id: OwnedRoomId) -> Result {
|
||||
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
|
||||
|
@ -932,17 +936,21 @@ pub(super) async fn force_append_latest_extremity(&self, room_id: OwnedRoomId) -
|
|||
.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 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()
|
||||
};
|
||||
|
||||
let pdu_id = latest_pdu.event_id();
|
||||
if !extremities.contains(&pdu_id) {
|
||||
extremities.push(pdu_id);
|
||||
if !extremities.contains(&selected_id.as_ref()) {
|
||||
extremities.push(&selected_id);
|
||||
}
|
||||
|
||||
self.services
|
||||
|
|
|
@ -237,9 +237,14 @@ pub enum DebugCommand {
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue