mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +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
|
|
@ -79,7 +79,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
# See also `rust-toolchain.toml`
|
||||
rust-version = "1.81.0"
|
||||
rust-version = "1.84.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -291,13 +291,13 @@
|
|||
"rust-manifest": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-tB9BZB6nRHDk5ELIVlGYlIjViLKBjQl52nC1avhcCwA=",
|
||||
"narHash": "sha256-dm4qOlaZ/uZ+O2TmOrWEjjMAzZNWAGE8S0ne79Fo8OA=",
|
||||
"type": "file",
|
||||
"url": "https://static.rust-lang.org/dist/channel-rust-1.81.0.toml"
|
||||
"url": "https://static.rust-lang.org/dist/channel-rust-1.84.0.toml"
|
||||
},
|
||||
"original": {
|
||||
"type": "file",
|
||||
"url": "https://static.rust-lang.org/dist/channel-rust-1.81.0.toml"
|
||||
"url": "https://static.rust-lang.org/dist/channel-rust-1.84.0.toml"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
rust-manifest = {
|
||||
# Keep version in sync with rust-toolchain.toml
|
||||
url = "https://static.rust-lang.org/dist/channel-rust-1.81.0.toml";
|
||||
url = "https://static.rust-lang.org/dist/channel-rust-1.84.0.toml";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
# If you're having trouble making the relevant changes, bug a maintainer.
|
||||
|
||||
[toolchain]
|
||||
channel = "1.81.0"
|
||||
channel = "1.84.0"
|
||||
components = [
|
||||
# For rust-analyzer
|
||||
"rust-src",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1030,8 +1030,8 @@ pub(crate) async fn send_transaction_message_route(
|
|||
services().users.add_cross_signing_keys(
|
||||
&user_id,
|
||||
&master_key,
|
||||
&self_signing_key,
|
||||
&None,
|
||||
self_signing_key.as_ref(),
|
||||
None,
|
||||
true,
|
||||
)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,10 +114,10 @@ async fn federation_self_test() -> Result<()> {
|
|||
)
|
||||
.await?;
|
||||
|
||||
if !response
|
||||
if response
|
||||
.server
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.name.as_deref() == Some(env!("CARGO_PKG_NAME")))
|
||||
.is_none_or(|s| s.name.as_deref() != Some(env!("CARGO_PKG_NAME")))
|
||||
{
|
||||
error!(?response, "unexpected server version");
|
||||
return Err(Error::BadConfig(
|
||||
|
|
|
|||
|
|
@ -488,8 +488,8 @@ impl KeyValueDatabase {
|
|||
for (userid, password) in self.userid_password.iter() {
|
||||
let password = utils::string_from_bytes(&password);
|
||||
|
||||
let empty_hashed_password = password
|
||||
.map_or(false, |password| {
|
||||
let empty_hashed_password =
|
||||
password.is_ok_and(|password| {
|
||||
utils::verify_password("", password)
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -182,9 +182,9 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
.ok();
|
||||
|
||||
let in_room = bridge_user_id
|
||||
.map_or(false, |id| self.is_joined(&id, room_id).unwrap_or(false))
|
||||
.is_some_and(|id| self.is_joined(&id, room_id).unwrap_or(false))
|
||||
|| self.room_members(room_id).any(|userid| {
|
||||
userid.map_or(false, |userid| {
|
||||
userid.is_ok_and(|userid| {
|
||||
appservice.users.is_match(userid.as_str())
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,12 +86,10 @@ impl service::sending::Data for KeyValueDatabase {
|
|||
) -> Box<dyn Iterator<Item = Result<(SendingEventType, RequestKey)>> + 'a>
|
||||
{
|
||||
let prefix = destination.get_prefix();
|
||||
return Box::new(self.servernameevent_data.scan_prefix(prefix).map(
|
||||
|(k, v)| {
|
||||
let k = RequestKey::new(k);
|
||||
parse_servercurrentevent(&k, v).map(|(_, ev)| (ev, k))
|
||||
},
|
||||
));
|
||||
Box::new(self.servernameevent_data.scan_prefix(prefix).map(|(k, v)| {
|
||||
let k = RequestKey::new(k);
|
||||
parse_servercurrentevent(&k, v).map(|(_, ev)| (ev, k))
|
||||
}))
|
||||
}
|
||||
|
||||
fn mark_as_active(
|
||||
|
|
|
|||
|
|
@ -522,8 +522,8 @@ impl service::users::Data for KeyValueDatabase {
|
|||
&self,
|
||||
user_id: &UserId,
|
||||
master_key: &Raw<CrossSigningKey>,
|
||||
self_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
user_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
self_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
user_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
notify: bool,
|
||||
) -> Result<()> {
|
||||
// TODO: Check signatures
|
||||
|
|
|
|||
|
|
@ -443,8 +443,8 @@ impl Service {
|
|||
&self.config.turn.secret
|
||||
}
|
||||
|
||||
pub(crate) fn emergency_password(&self) -> &Option<String> {
|
||||
&self.config.emergency_password
|
||||
pub(crate) fn emergency_password(&self) -> Option<&str> {
|
||||
self.config.emergency_password.as_deref()
|
||||
}
|
||||
|
||||
/// If the emergency password option is set, attempts to set the emergency
|
||||
|
|
@ -455,10 +455,9 @@ impl Service {
|
|||
let inner = || -> Result<bool> {
|
||||
let admin_bot = self.admin_bot_user_id.as_ref();
|
||||
|
||||
services().users.set_password(
|
||||
admin_bot,
|
||||
self.emergency_password().as_deref(),
|
||||
)?;
|
||||
services()
|
||||
.users
|
||||
.set_password(admin_bot, self.emergency_password())?;
|
||||
|
||||
let (ruleset, res) = match self.emergency_password() {
|
||||
Some(_) => (Ruleset::server_default(admin_bot), Ok(true)),
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl Service {
|
|||
let mut results = Vec::new();
|
||||
|
||||
while let Some(current_room) = {
|
||||
while stack.last().map_or(false, Vec::is_empty) {
|
||||
while stack.last().is_some_and(Vec::is_empty) {
|
||||
stack.pop();
|
||||
}
|
||||
if stack.is_empty() {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl Service {
|
|||
})
|
||||
})
|
||||
.transpose()?
|
||||
.map_or(false, |ignored| {
|
||||
.is_some_and(|ignored| {
|
||||
ignored
|
||||
.content
|
||||
.ignored_users
|
||||
|
|
|
|||
|
|
@ -726,9 +726,10 @@ impl Service {
|
|||
let matching_users = |users: &NamespaceRegex| {
|
||||
appservice.users.is_match(pdu.sender.as_str())
|
||||
|| pdu.kind == TimelineEventType::RoomMember
|
||||
&& pdu.state_key.as_ref().map_or(false, |state_key| {
|
||||
users.is_match(state_key)
|
||||
})
|
||||
&& pdu
|
||||
.state_key
|
||||
.as_ref()
|
||||
.is_some_and(|state_key| users.is_match(state_key))
|
||||
};
|
||||
let matching_aliases = |aliases: &NamespaceRegex| {
|
||||
services()
|
||||
|
|
|
|||
|
|
@ -464,8 +464,8 @@ impl Service {
|
|||
&self,
|
||||
user_id: &UserId,
|
||||
master_key: &Raw<CrossSigningKey>,
|
||||
self_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
user_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
self_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
user_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
notify: bool,
|
||||
) -> Result<()> {
|
||||
self.db.add_cross_signing_keys(
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ pub(crate) trait Data: Send + Sync {
|
|||
&self,
|
||||
user_id: &UserId,
|
||||
master_key: &Raw<CrossSigningKey>,
|
||||
self_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
user_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
self_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
user_signing_key: Option<&Raw<CrossSigningKey>>,
|
||||
notify: bool,
|
||||
) -> Result<()>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue