mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-19 00:31:24 +01:00
largely stop using RoomCreateEventContent
This became a problem because #foundation-office:matrix.org has a malformed create event with its `predecessor` set to a string instead of a map. The solution to this is, unfortunately, to do more shotgun parsing to extract only the desired fields rather than trying to parse the entire content every time. To prevent this kind of problem from happening again, `RoomCreateEventContent` must only be used for creating new PDUs, existing PDUs must be shotgun-parsed.
This commit is contained in:
parent
9d0cf428a5
commit
51b30d9ba3
4 changed files with 50 additions and 51 deletions
|
|
@ -7,9 +7,10 @@ use std::{
|
|||
use ruma::{
|
||||
api::client::error::ErrorKind,
|
||||
events::{
|
||||
room::member::MembershipState, AnyStrippedStateEvent, StateEventType,
|
||||
TimelineEventType,
|
||||
room::{create::PreviousRoom, member::MembershipState},
|
||||
AnyStrippedStateEvent, StateEventType, TimelineEventType,
|
||||
},
|
||||
room::RoomType,
|
||||
serde::Raw,
|
||||
state_res::{self, StateMap},
|
||||
EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId,
|
||||
|
|
@ -51,6 +52,34 @@ impl ExtractCreateContent for ExtractVersion {
|
|||
}
|
||||
}
|
||||
|
||||
/// Extract the `type` from an `m.room.create` event
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct ExtractType {
|
||||
#[serde(rename = "type")]
|
||||
kind: Option<RoomType>,
|
||||
}
|
||||
|
||||
impl ExtractCreateContent for ExtractType {
|
||||
type Extract = Option<RoomType>;
|
||||
|
||||
fn extract(self) -> Self::Extract {
|
||||
self.kind
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct ExtractPredecessor {
|
||||
predecessor: Option<PreviousRoom>,
|
||||
}
|
||||
|
||||
impl ExtractCreateContent for ExtractPredecessor {
|
||||
type Extract = Option<PreviousRoom>;
|
||||
|
||||
fn extract(self) -> Self::Extract {
|
||||
self.predecessor
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue