mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 04:37:00 +00:00
fix: Replace our local extremity tracking when joining a disconnected room remotely
This commit is contained in:
1 file changed
+22
-1
@@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Pdu, Result, Server, debug, debug_info, debug_warn, err, error, info, is_true,
|
Err, Event, Pdu, Result, Server, debug, debug_info, debug_warn, err, error, info, is_true,
|
||||||
matrix::{
|
matrix::{
|
||||||
StateKey,
|
StateKey,
|
||||||
event::{gen_event_id, gen_event_id_canonical_json},
|
event::{gen_event_id, gen_event_id_canonical_json},
|
||||||
@@ -577,6 +577,11 @@ impl Service {
|
|||||||
if !auth_check {
|
if !auth_check {
|
||||||
return Err!(Request(Forbidden("Auth check failed")));
|
return Err!(Request(Forbidden("Auth check failed")));
|
||||||
}
|
}
|
||||||
|
let resident_before = self
|
||||||
|
.services
|
||||||
|
.state_cache
|
||||||
|
.server_in_room(self.services.globals.server_name(), room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
info!("Compressing state from send_join");
|
info!("Compressing state from send_join");
|
||||||
let compressed: CompressedState = self
|
let compressed: CompressedState = self
|
||||||
@@ -637,6 +642,22 @@ impl Service {
|
|||||||
self.services
|
self.services
|
||||||
.state
|
.state
|
||||||
.set_room_state(room_id, statehash_after_join, &state_lock);
|
.set_room_state(room_id, statehash_after_join, &state_lock);
|
||||||
|
if !resident_before {
|
||||||
|
// NOTE: We replace local extremities for this room if we were not a resident
|
||||||
|
// before. We might be doing a remote join to satisfy restricted join rules,
|
||||||
|
// so we don't want to do this if we're already a resident. Otherwise, we
|
||||||
|
// want to replace our forward extremities whole-sale in case we were
|
||||||
|
// desynced.
|
||||||
|
info!("Replacing local forward extremities");
|
||||||
|
self.services
|
||||||
|
.state
|
||||||
|
.set_forward_extremities(
|
||||||
|
room_id,
|
||||||
|
std::iter::once(parsed_join_pdu.event_id()),
|
||||||
|
&state_lock,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user