fix: Proper S2S Backfill visibility handling

This commit is contained in:
Nyaaori 2022-11-26 13:03:19 +01:00
parent 3518ee048d
commit d47e1761ec
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E

View file

@ -112,10 +112,25 @@ impl Service {
});
let visibility = match history_visibility {
Some(HistoryVisibility::Joined) => {
// Look at all members in the room from this server; one of them
// triggered a backfill. Was one of them a member in the past,
// at this event?
Some(HistoryVisibility::WorldReadable) => {
// Allow if event was sent while world readable
true
}
Some(HistoryVisibility::Invited) => {
let mut visible = false;
// Allow if any member on requesting server was invited or joined, else deny
for member in current_server_members {
if self.user_was_invited(shortstatehash, &member)?
|| self.user_was_joined(shortstatehash, &member)?
{
visible = true;
break;
}
}
visible
}
_ => {
// Allow if any member on requested server was joined, else deny
let mut visible = false;
for member in current_server_members {
if self.user_was_joined(shortstatehash, &member)? {
@ -125,17 +140,6 @@ impl Service {
}
visible
}
Some(HistoryVisibility::Invited) => {
let mut visible = false;
for member in current_server_members {
if self.user_was_invited(shortstatehash, &member)? {
visible = true;
break;
}
}
visible
}
_ => false,
};
self.server_visibility_cache