fix: repair after broken join

The bug that caused broken joins was fixed here:
a5f004d7e9

But that commit doesn't repair those joins afterwards because the broken
join event is still in the auth chain. This commit will leave out the
the member join event from the auth_events in leave->* transitions.

Also see https://github.com/matrix-org/matrix-doc/issues/3695
This commit is contained in:
Timo Kösters 2022-02-03 11:44:29 +01:00
parent 9ef3abacd4
commit 3ff574af81
No known key found for this signature in database
GPG key ID: 356E705610F626D5

View file

@ -295,6 +295,22 @@ impl Rooms {
sauthevents.remove(&shortstatekey).map(|k| (k, event_id)) sauthevents.remove(&shortstatekey).map(|k| (k, event_id))
}) })
.filter_map(|(k, event_id)| self.get_pdu(&event_id).ok().flatten().map(|pdu| (k, pdu))) .filter_map(|(k, event_id)| self.get_pdu(&event_id).ok().flatten().map(|pdu| (k, pdu)))
.filter(|(_, pdu)| {
if pdu.kind != EventType::RoomMember {
return true;
}
#[derive(Deserialize)]
struct ExtractMembership {
membership: MembershipState,
}
// Leave out auth events where the membership is leave
match serde_json::from_str::<ExtractMembership>(pdu.content.get()) {
Ok(e) => e.membership != MembershipState::Leave,
Err(_) => true,
}
})
.collect()) .collect())
} }