mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
Merge branch 'full-invite-state' into 'main'
prevent stripping the room's invite state Closes #97 See merge request matrix/grapevine!159
This commit is contained in:
commit
c5e0b09881
2 changed files with 33 additions and 6 deletions
|
|
@ -242,6 +242,8 @@ This will be the first release of Grapevine since it was forked from Conduit
|
||||||
([!158](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/158))
|
([!158](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/158))
|
||||||
28. Fix read receipts not being sent over federation (or only arbitrarily late)
|
28. Fix read receipts not being sent over federation (or only arbitrarily late)
|
||||||
([!162](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/162))
|
([!162](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/162))
|
||||||
|
29. Prevent stripping the room's invite state.
|
||||||
|
([!159](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/159))
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
events::{AnyStrippedStateEvent, AnySyncStateEvent},
|
events::{AnyStateEvent, AnyStrippedStateEvent, AnySyncStateEvent},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
|
|
@ -466,11 +466,36 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let state = serde_json::from_slice(&state).map_err(|_| {
|
let state: Vec<Raw<AnyStateEvent>> =
|
||||||
Error::bad_database(
|
serde_json::from_slice(&state).map_err(|_| {
|
||||||
"Invalid state in userroomid_invitestate.",
|
Error::bad_database(
|
||||||
)
|
"Invalid state in userroomid_invitestate.",
|
||||||
})?;
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
// The semantics here are omitted by the spec, as the example
|
||||||
|
// does not strip the membership event: we cast the
|
||||||
|
// "m.room.member" event to avoid stripping it.
|
||||||
|
// See: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv2inviteroomideventid
|
||||||
|
let state: Vec<_> = state
|
||||||
|
.into_iter()
|
||||||
|
.map(|raw| {
|
||||||
|
match raw.deserialize().map_err(|_| {
|
||||||
|
Error::bad_database(
|
||||||
|
"Invalid state in userroomid_invitestate.",
|
||||||
|
)
|
||||||
|
})? {
|
||||||
|
AnyStateEvent::RoomMember(_) => Ok(raw.cast()),
|
||||||
|
_ => serde_json::from_str(raw.json().get())
|
||||||
|
.map_err(|_| {
|
||||||
|
Error::bad_database(
|
||||||
|
"Invalid state in \
|
||||||
|
userroomid_invitestate.",
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Result<_>>()?;
|
||||||
|
|
||||||
Ok((room_id, state))
|
Ok((room_id, state))
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue