mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
Update MSRV to 1.84.0
And appease clippy (`__CARGO_FIX_YOLO=1 cargo clippy --fix` plus some manual type shuffling).
This commit is contained in:
parent
5616510727
commit
175a62007d
20 changed files with 83 additions and 89 deletions
|
|
@ -133,62 +133,59 @@ pub(crate) async fn create_room_route(
|
|||
};
|
||||
let room_version = RoomVersion::try_from(&room_version_id)?;
|
||||
|
||||
let content = match &body.creation_content {
|
||||
Some(content) => {
|
||||
let mut content = content
|
||||
.deserialize_as::<CanonicalJsonObject>()
|
||||
.expect("Invalid creation content");
|
||||
let content = if let Some(content) = &body.creation_content {
|
||||
let mut content = content
|
||||
.deserialize_as::<CanonicalJsonObject>()
|
||||
.expect("Invalid creation content");
|
||||
|
||||
if room_version.create_event_creator_prop {
|
||||
content.insert(
|
||||
"creator".into(),
|
||||
json!(&sender_user).try_into().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?,
|
||||
);
|
||||
}
|
||||
if room_version.create_event_creator_prop {
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version_id.as_str()).try_into().map_err(|_| {
|
||||
"creator".into(),
|
||||
json!(&sender_user).try_into().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?,
|
||||
);
|
||||
content
|
||||
}
|
||||
None => {
|
||||
let content = if room_version.create_event_creator_prop {
|
||||
RoomCreateEventContent::new_v1(sender_user.to_owned())
|
||||
} else {
|
||||
RoomCreateEventContent::new_v11()
|
||||
};
|
||||
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&content)
|
||||
.map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?
|
||||
.get(),
|
||||
)
|
||||
.unwrap();
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version_id.as_str()).try_into().map_err(|_| {
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version_id.as_str()).try_into().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?,
|
||||
);
|
||||
content
|
||||
} else {
|
||||
let content = if room_version.create_event_creator_prop {
|
||||
RoomCreateEventContent::new_v1(sender_user.to_owned())
|
||||
} else {
|
||||
RoomCreateEventContent::new_v11()
|
||||
};
|
||||
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&content)
|
||||
.map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?,
|
||||
);
|
||||
content
|
||||
}
|
||||
})?
|
||||
.get(),
|
||||
)
|
||||
.unwrap();
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version_id.as_str()).try_into().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
)
|
||||
})?,
|
||||
);
|
||||
content
|
||||
};
|
||||
|
||||
// Validate creation content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue