mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-26 12:55:22 +02:00
feat: allow overriding the "most recent event" when forcing a state download (#853)
Some checks failed
Release Docker Image / define-variables (push) Failing after 3s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Rust Checks / Format (push) Failing after 2s
Documentation / Build and Deploy Documentation (push) Failing after 13s
Rust Checks / Clippy (push) Failing after 32s
Rust Checks / Cargo Test (push) Failing after 32s
Some checks failed
Release Docker Image / define-variables (push) Failing after 3s
Release Docker Image / build-image (linux/amd64, linux-amd64) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, linux-arm64) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Rust Checks / Format (push) Failing after 2s
Documentation / Build and Deploy Documentation (push) Failing after 13s
Rust Checks / Clippy (push) Failing after 32s
Rust Checks / Cargo Test (push) Failing after 32s
Add option to select which event to set the state at to, for the force-set-room-state admin command. This allows us to work around issues where the latest PDU is one that remote servers don't know about (i.e. failed federation for whatever reason) Closes #852 Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/853 Reviewed-by: Jade Ellis <jade@ellis.link> Co-authored-by: nex <nex@noreply.forgejo.ellis.link> Co-committed-by: nex <nex@noreply.forgejo.ellis.link>
This commit is contained in:
parent
d6fd30393c
commit
e508b1197f
2 changed files with 26 additions and 14 deletions
|
@ -239,10 +239,11 @@ pub(super) async fn get_remote_pdu(
|
|||
})
|
||||
.await
|
||||
{
|
||||
| Err(e) =>
|
||||
| Err(e) => {
|
||||
return Err!(
|
||||
"Remote server did not have PDU or failed sending request to remote server: {e}"
|
||||
),
|
||||
);
|
||||
},
|
||||
| Ok(response) => {
|
||||
let json: CanonicalJsonObject =
|
||||
serde_json::from_str(response.pdu.get()).map_err(|e| {
|
||||
|
@ -384,8 +385,9 @@ pub(super) async fn change_log_level(&self, filter: Option<String>, reset: bool)
|
|||
.reload
|
||||
.reload(&old_filter_layer, Some(handles))
|
||||
{
|
||||
| Err(e) =>
|
||||
return Err!("Failed to modify and reload the global tracing log level: {e}"),
|
||||
| Err(e) => {
|
||||
return Err!("Failed to modify and reload the global tracing log level: {e}");
|
||||
},
|
||||
| Ok(()) => {
|
||||
let value = &self.services.server.config.log;
|
||||
let out = format!("Successfully changed log level back to config value {value}");
|
||||
|
@ -408,8 +410,9 @@ pub(super) async fn change_log_level(&self, filter: Option<String>, reset: bool)
|
|||
.reload(&new_filter_layer, Some(handles))
|
||||
{
|
||||
| Ok(()) => return self.write_str("Successfully changed log level").await,
|
||||
| Err(e) =>
|
||||
return Err!("Failed to modify and reload the global tracing log level: {e}"),
|
||||
| Err(e) => {
|
||||
return Err!("Failed to modify and reload the global tracing log level: {e}");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -529,6 +532,7 @@ pub(super) async fn force_set_room_state_from_server(
|
|||
&self,
|
||||
room_id: OwnedRoomId,
|
||||
server_name: OwnedServerName,
|
||||
at_event: Option<OwnedEventId>,
|
||||
) -> Result {
|
||||
if !self
|
||||
.services
|
||||
|
@ -540,13 +544,18 @@ pub(super) async fn force_set_room_state_from_server(
|
|||
return Err!("We are not participating in the room / we don't know about the room ID.");
|
||||
}
|
||||
|
||||
let first_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 at_event_id = match at_event {
|
||||
| Some(event_id) => event_id,
|
||||
| None => 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
|
||||
.clone(),
|
||||
};
|
||||
|
||||
let room_version = self.services.rooms.state.get_room_version(&room_id).await?;
|
||||
|
||||
|
@ -557,7 +566,7 @@ pub(super) async fn force_set_room_state_from_server(
|
|||
.sending
|
||||
.send_federation_request(&server_name, get_room_state::v1::Request {
|
||||
room_id: room_id.clone(),
|
||||
event_id: first_pdu.event_id.clone(),
|
||||
event_id: at_event_id,
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -177,6 +177,9 @@ pub(super) enum DebugCommand {
|
|||
room_id: OwnedRoomId,
|
||||
/// The server we will use to query the room state for
|
||||
server_name: OwnedServerName,
|
||||
/// The event ID of the latest known PDU in the room. Will be found
|
||||
/// automatically if not provided.
|
||||
event_id: Option<OwnedEventId>,
|
||||
},
|
||||
|
||||
/// - Runs a server name through conduwuit's true destination resolution
|
||||
|
|
Loading…
Add table
Reference in a new issue