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
|
|
@ -150,8 +150,8 @@ pub(crate) async fn upload_signing_keys_route(
|
|||
services().users.add_cross_signing_keys(
|
||||
sender_user,
|
||||
master_key,
|
||||
&body.self_signing_key,
|
||||
&body.user_signing_key,
|
||||
body.self_signing_key.as_ref(),
|
||||
body.user_signing_key.as_ref(),
|
||||
// notify so that other users see the new keys
|
||||
true,
|
||||
)?;
|
||||
|
|
@ -428,7 +428,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
|||
let raw = serde_json::from_value(json)
|
||||
.expect("Raw::from_value always works");
|
||||
services().users.add_cross_signing_keys(
|
||||
&user, &raw, &None, &None,
|
||||
&user, &raw, None, None,
|
||||
// Dont notify. A notification would trigger another key
|
||||
// request resulting in an endless loop
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -232,11 +232,11 @@ pub(crate) async fn login_route(
|
|||
let token = utils::random_string(TOKEN_LENGTH);
|
||||
|
||||
// Determine if device_id was provided and exists in the db for this user
|
||||
let device_exists = body.device_id.as_ref().map_or(false, |device_id| {
|
||||
let device_exists = body.device_id.as_ref().is_some_and(|device_id| {
|
||||
services()
|
||||
.users
|
||||
.all_device_ids(&user_id)
|
||||
.any(|x| x.as_ref().map_or(false, |v| v == device_id))
|
||||
.any(|x| x.as_ref().is_ok_and(|v| v == device_id))
|
||||
});
|
||||
|
||||
if device_exists {
|
||||
|
|
|
|||
|
|
@ -60,10 +60,9 @@ pub(crate) async fn search_users_route(
|
|||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(&room, &StateEventType::RoomJoinRules, "")
|
||||
.map_or(false, |event| {
|
||||
event.map_or(false, |event| {
|
||||
serde_json::from_str(event.content.get()).map_or(
|
||||
false,
|
||||
.is_ok_and(|event| {
|
||||
event.is_some_and(|event| {
|
||||
serde_json::from_str(event.content.get()).is_ok_and(
|
||||
|r: RoomJoinRulesEventContent| {
|
||||
r.join_rule == JoinRule::Public
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue