mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-06-27 16:35:59 +00:00
chore(rust): upgrade to 1.85.0
required for axum 0.8.x
This commit is contained in:
parent
3248efbe4b
commit
b44b5641f0
15 changed files with 35 additions and 44 deletions
|
@ -19,7 +19,7 @@ repository = "https://gitlab.com/famedly/conduit"
|
||||||
version = "0.11.0-alpha"
|
version = "0.11.0-alpha"
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
rust-version = "1.83.0"
|
rust-version = "1.85.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
file = ./rust-toolchain.toml;
|
file = ./rust-toolchain.toml;
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
|
sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# If you're having trouble making the relevant changes, bug a maintainer.
|
# If you're having trouble making the relevant changes, bug a maintainer.
|
||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.83.0"
|
channel = "1.85.0"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|
|
@ -656,7 +656,7 @@ pub async fn joined_members_route(
|
||||||
Ok(joined_members::v3::Response { joined })
|
Ok(joined_members::v3::Response { joined })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn invite_helper<'a>(
|
pub(crate) async fn invite_helper(
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
|
@ -182,11 +182,11 @@ pub async fn login_route(body: Ruma<login::v3::Request>) -> Result<login::v3::Re
|
||||||
let token = utils::random_string(TOKEN_LENGTH);
|
let token = utils::random_string(TOKEN_LENGTH);
|
||||||
|
|
||||||
// Determine if device_id was provided and exists in the db for this user
|
// 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()
|
services()
|
||||||
.users
|
.users
|
||||||
.all_device_ids(&user_id)
|
.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 {
|
if device_exists {
|
||||||
|
|
|
@ -818,8 +818,8 @@ async fn load_joined_room(
|
||||||
.ok()
|
.ok()
|
||||||
});
|
});
|
||||||
|
|
||||||
let joined_since_last_sync = since_sender_member
|
let joined_since_last_sync =
|
||||||
.map_or(true, |member| member.membership != MembershipState::Join);
|
since_sender_member.is_none_or(|member| member.membership != MembershipState::Join);
|
||||||
|
|
||||||
if since_shortstatehash.is_none() || joined_since_last_sync {
|
if since_shortstatehash.is_none() || joined_since_last_sync {
|
||||||
// Probably since = 0, we will do an initial sync
|
// Probably since = 0, we will do an initial sync
|
||||||
|
@ -1402,7 +1402,7 @@ pub async fn sync_events_v5_route(
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let joined_since_last_sync = since_sender_member
|
let joined_since_last_sync = since_sender_member
|
||||||
.map_or(true, |member| member.membership != MembershipState::Join);
|
.is_none_or(|member| member.membership != MembershipState::Join);
|
||||||
|
|
||||||
let new_encrypted_room = encrypted_room && since_encryption.is_none();
|
let new_encrypted_room = encrypted_room && since_encryption.is_none();
|
||||||
if encrypted_room {
|
if encrypted_room {
|
||||||
|
|
|
@ -61,12 +61,11 @@ pub async fn search_users_route(
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.room_state_get(&room, &StateEventType::RoomJoinRules, "")
|
.room_state_get(&room, &StateEventType::RoomJoinRules, "")
|
||||||
.map_or(false, |event| {
|
.is_ok_and(|event| {
|
||||||
event.map_or(false, |event| {
|
event.is_some_and(|event| {
|
||||||
serde_json::from_str(event.content.get())
|
serde_json::from_str(event.content.get()).is_ok_and(
|
||||||
.map_or(false, |r: RoomJoinRulesEventContent| {
|
|r: RoomJoinRulesEventContent| r.join_rule == JoinRule::Public,
|
||||||
r.join_rule == JoinRule::Public
|
)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,10 +22,7 @@ impl service::pusher::Data for KeyValueDatabase {
|
||||||
let mut key = sender.as_bytes().to_vec();
|
let mut key = sender.as_bytes().to_vec();
|
||||||
key.push(0xff);
|
key.push(0xff);
|
||||||
key.extend_from_slice(ids.pushkey.as_bytes());
|
key.extend_from_slice(ids.pushkey.as_bytes());
|
||||||
self.senderkey_pusher
|
self.senderkey_pusher.remove(&key).map(|_| ())
|
||||||
.remove(&key)
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,9 +221,9 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let in_room = bridge_user_id
|
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| {
|
|| self.room_members(room_id).any(|userid| {
|
||||||
userid.map_or(false, |userid| appservice.users.is_match(userid.as_str()))
|
userid.is_ok_and(|userid| appservice.users.is_match(userid.as_str()))
|
||||||
});
|
});
|
||||||
|
|
||||||
self.appservice_in_room_cache
|
self.appservice_in_room_cache
|
||||||
|
@ -273,7 +273,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn server_in_room<'a>(&'a self, server: &ServerName, room_id: &RoomId) -> Result<bool> {
|
fn server_in_room(&self, server: &ServerName, room_id: &RoomId) -> Result<bool> {
|
||||||
let mut key = server.as_bytes().to_vec();
|
let mut key = server.as_bytes().to_vec();
|
||||||
key.push(0xff);
|
key.push(0xff);
|
||||||
key.extend_from_slice(room_id.as_bytes());
|
key.extend_from_slice(room_id.as_bytes());
|
||||||
|
|
|
@ -491,7 +491,7 @@ impl KeyValueDatabase {
|
||||||
for (userid, password) in db.userid_password.iter() {
|
for (userid, password) in db.userid_password.iter() {
|
||||||
let password = utils::string_from_bytes(&password);
|
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| {
|
||||||
argon2::verify_encoded(&password, b"").unwrap_or(false)
|
argon2::verify_encoded(&password, b"").unwrap_or(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -87,13 +87,13 @@ impl Service {
|
||||||
let events_after: Vec<_> = relations_until // TODO: should be relations_after
|
let events_after: Vec<_> = relations_until // TODO: should be relations_after
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, pdu)| {
|
.filter(|(_, pdu)| {
|
||||||
filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t)
|
filter_event_type.as_ref().is_none_or(|t| &pdu.kind == t)
|
||||||
&& if let Ok(content) =
|
&& if let Ok(content) =
|
||||||
serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get())
|
serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get())
|
||||||
{
|
{
|
||||||
filter_rel_type
|
filter_rel_type
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |r| &content.relates_to.rel_type == r)
|
.is_none_or(|r| &content.relates_to.rel_type == r)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -135,13 +135,13 @@ impl Service {
|
||||||
let events_before: Vec<_> = relations_until
|
let events_before: Vec<_> = relations_until
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, pdu)| {
|
.filter(|(_, pdu)| {
|
||||||
filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t)
|
filter_event_type.as_ref().is_none_or(|t| &pdu.kind == t)
|
||||||
&& if let Ok(content) =
|
&& if let Ok(content) =
|
||||||
serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get())
|
serde_json::from_str::<ExtractRelatesToEventId>(pdu.content.get())
|
||||||
{
|
{
|
||||||
filter_rel_type
|
filter_rel_type
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |r| &content.relates_to.rel_type == r)
|
.is_none_or(|r| &content.relates_to.rel_type == r)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,12 @@ pub struct Service {
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
|
pub fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
|
||||||
self.db.index_pdu(shortroomid, pdu_id, message_body)
|
self.db.index_pdu(shortroomid, pdu_id, message_body)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn deindex_pdu<'a>(
|
pub fn deindex_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
|
||||||
&self,
|
|
||||||
shortroomid: u64,
|
|
||||||
pdu_id: &[u8],
|
|
||||||
message_body: &str,
|
|
||||||
) -> Result<()> {
|
|
||||||
self.db.deindex_pdu(shortroomid, pdu_id, message_body)
|
self.db.deindex_pdu(shortroomid, pdu_id, message_body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ fn next_room_to_traverse(
|
||||||
stack: &mut Vec<Vec<(OwnedRoomId, Vec<OwnedServerName>)>>,
|
stack: &mut Vec<Vec<(OwnedRoomId, Vec<OwnedServerName>)>>,
|
||||||
parents: &mut VecDeque<OwnedRoomId>,
|
parents: &mut VecDeque<OwnedRoomId>,
|
||||||
) -> Option<(OwnedRoomId, Vec<OwnedServerName>)> {
|
) -> Option<(OwnedRoomId, Vec<OwnedServerName>)> {
|
||||||
while stack.last().map_or(false, |s| s.is_empty()) {
|
while stack.last().is_some_and(|s| s.is_empty()) {
|
||||||
stack.pop();
|
stack.pop();
|
||||||
parents.pop_back();
|
parents.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -663,7 +663,7 @@ async fn get_stripped_space_child_events(
|
||||||
if serde_json::from_str::<SpaceChildEventContent>(pdu.content.get())
|
if serde_json::from_str::<SpaceChildEventContent>(pdu.content.get())
|
||||||
.ok()
|
.ok()
|
||||||
.map(|c| c.via)
|
.map(|c| c.via)
|
||||||
.map_or(true, |v| v.is_empty())
|
.is_none_or(|v| v.is_empty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ impl Service {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map_or(false, |ignored| {
|
.is_some_and(|ignored| {
|
||||||
ignored
|
ignored
|
||||||
.content
|
.content
|
||||||
.ignored_users
|
.ignored_users
|
||||||
|
@ -236,7 +236,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn server_in_room<'a>(&'a self, server: &ServerName, room_id: &RoomId) -> Result<bool> {
|
pub fn server_in_room(&self, server: &ServerName, room_id: &RoomId) -> Result<bool> {
|
||||||
self.db.server_in_room(server, room_id)
|
self.db.server_in_room(server, room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ impl Service {
|
||||||
///
|
///
|
||||||
/// Returns pdu id
|
/// Returns pdu id
|
||||||
#[tracing::instrument(skip(self, pdu, pdu_json, leaves))]
|
#[tracing::instrument(skip(self, pdu, pdu_json, leaves))]
|
||||||
pub async fn append_pdu<'a>(
|
pub async fn append_pdu(
|
||||||
&self,
|
&self,
|
||||||
pdu: &PduEvent,
|
pdu: &PduEvent,
|
||||||
mut pdu_json: CanonicalJsonObject,
|
mut pdu_json: CanonicalJsonObject,
|
||||||
|
@ -612,8 +612,8 @@ impl Service {
|
||||||
services().globals.server_name() == pdu.sender.server_name()
|
services().globals.server_name() == pdu.sender.server_name()
|
||||||
&& appservice.is_user_match(&pdu.sender)
|
&& appservice.is_user_match(&pdu.sender)
|
||||||
|| pdu.kind == TimelineEventType::RoomMember
|
|| pdu.kind == TimelineEventType::RoomMember
|
||||||
&& pdu.state_key.as_ref().map_or(false, |state_key| {
|
&& pdu.state_key.as_ref().is_some_and(|state_key| {
|
||||||
UserId::parse(state_key).map_or(false, |user_id| {
|
UserId::parse(state_key).is_ok_and(|user_id| {
|
||||||
services().globals.server_name() == user_id.server_name()
|
services().globals.server_name() == user_id.server_name()
|
||||||
&& appservice.is_user_match(&user_id)
|
&& appservice.is_user_match(&user_id)
|
||||||
})
|
})
|
||||||
|
@ -633,8 +633,8 @@ impl Service {
|
||||||
"",
|
"",
|
||||||
) {
|
) {
|
||||||
serde_json::from_str::<RoomCanonicalAliasEventContent>(pdu.content.get())
|
serde_json::from_str::<RoomCanonicalAliasEventContent>(pdu.content.get())
|
||||||
.map_or(false, |content| {
|
.is_ok_and(|content| {
|
||||||
content.alias.map_or(false, |alias| {
|
content.alias.is_some_and(|alias| {
|
||||||
appservice.aliases.is_match(alias.as_str())
|
appservice.aliases.is_match(alias.as_str())
|
||||||
}) || content
|
}) || content
|
||||||
.alt_aliases
|
.alt_aliases
|
||||||
|
@ -1044,7 +1044,7 @@ impl Service {
|
||||||
/// Append the incoming event setting the state snapshot to the state from the
|
/// Append the incoming event setting the state snapshot to the state from the
|
||||||
/// server that sent the event.
|
/// server that sent the event.
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
pub async fn append_incoming_pdu<'a>(
|
pub async fn append_incoming_pdu(
|
||||||
&self,
|
&self,
|
||||||
pdu: &PduEvent,
|
pdu: &PduEvent,
|
||||||
pdu_json: CanonicalJsonObject,
|
pdu_json: CanonicalJsonObject,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue