Skip to content

Commit dc253ad

Browse files
committed
refactor: Batch of remaining fixes
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent e687435 commit dc253ad

File tree

10 files changed

+17
-21
lines changed

10 files changed

+17
-21
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,9 +2402,7 @@ impl TryFrom<AllowRule> for RumaAllowRule {
24022402
match value {
24032403
AllowRule::RoomMembership { room_id } => {
24042404
let room_id = RoomId::parse(room_id)?;
2405-
Ok(Self::RoomMembership(ruma::events::room::join_rules::RoomMembership::new(
2406-
room_id,
2407-
)))
2405+
Ok(Self::RoomMembership(ruma::room::RoomMembership::new(room_id)))
24082406
}
24092407
AllowRule::Custom { json } => Ok(Self::_Custom(Box::new(serde_json::from_str(&json)?))),
24102408
}

bindings/matrix-sdk-ffi/src/room/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl Room {
484484
/// # Errors
485485
///
486486
/// Returns an error if the room is not found or on rate limit
487-
pub async fn report_room(&self, reason: Option<String>) -> Result<(), ClientError> {
487+
pub async fn report_room(&self, reason: String) -> Result<(), ClientError> {
488488
self.inner.report_room(reason).await?;
489489

490490
Ok(())

crates/matrix-sdk-crypto/src/file_encryption/attachments.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,19 @@ impl<'a, R: Read + 'a> AttachmentDecryptor<'a, R> {
136136

137137
let hash =
138138
info.hashes.get("sha256").ok_or(DecryptorError::MissingHash)?.as_bytes().to_owned();
139-
let mut key = info.key.k.into_inner();
139+
let key = info.key.k.as_bytes();
140140
let iv = info.iv.into_inner();
141141

142142
if key.len() != KEY_SIZE {
143143
return Err(DecryptorError::KeyNonceLength);
144144
}
145145

146-
let key_array = GenericArray::from_slice(&key);
146+
let key_array = GenericArray::from_slice(key);
147147
let iv = GenericArray::from_exact_iter(iv).ok_or(DecryptorError::KeyNonceLength)?;
148148

149149
let sha = Sha256::default();
150150

151151
let aes = Aes256Ctr::new(key_array, &iv);
152-
key.zeroize();
153152

154153
Ok(AttachmentDecryptor { inner: input, expected_hash: hash, sha, aes })
155154
}

crates/matrix-sdk-crypto/src/machine/test_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn bootstrap_requests_to_keys_query_response(
334334
/// Helper for [`create_signed_device_of_unverified_user`] and
335335
/// [`create_unsigned_device`].
336336
fn dummy_verification_machine() -> VerificationMachine {
337-
let account = Account::new(user_id!("@TEST_USER:example.com"));
337+
let account = Account::new(user_id!("@test_user:example.com"));
338338
VerificationMachine::new(
339339
account.deref().clone(),
340340
Arc::new(Mutex::new(PrivateCrossSigningIdentity::new(account.user_id().to_owned()))),

crates/matrix-sdk/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use ruma::{
4848
directory::{get_public_rooms, get_public_rooms_filtered},
4949
discovery::{
5050
discover_homeserver::{self, RtcFocusInfo},
51-
get_capabilities::{self, Capabilities},
51+
get_capabilities::{self, v3::Capabilities},
5252
get_supported_versions,
5353
},
5454
error::ErrorKind,

crates/matrix-sdk/src/encryption/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,9 @@ pub struct OAuthCrossSigningResetInfo {
348348

349349
impl OAuthCrossSigningResetInfo {
350350
fn from_auth_info(auth_info: &UiaaInfo) -> Result<Self> {
351-
let parameters =
352-
serde_json::from_str::<OAuthCrossSigningResetUiaaParameters>(auth_info.params.get())?;
351+
let parameters = serde_json::from_str::<OAuthCrossSigningResetUiaaParameters>(
352+
auth_info.params.as_ref().map(|value| value.get()).unwrap_or_default(),
353+
)?;
353354

354355
Ok(OAuthCrossSigningResetInfo { approval_url: parameters.reset.url })
355356
}

crates/matrix-sdk/src/event_handler/static_events.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616

1717
use ruma::{
1818
events::{
19-
self,
20-
presence::{PresenceEvent, PresenceEventContent},
21-
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
22-
AnySyncEphemeralRoomEvent, AnySyncMessageLikeEvent, AnySyncStateEvent,
23-
AnySyncTimelineEvent, AnyToDeviceEvent, EphemeralRoomEventContent,
19+
self, presence::PresenceEvent, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
20+
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageLikeEvent,
21+
AnySyncStateEvent, AnySyncTimelineEvent, AnyToDeviceEvent, EphemeralRoomEventContent,
2422
GlobalAccountDataEventContent, MessageLikeEventContent, PossiblyRedactedStateEventContent,
2523
RedactContent, RedactedMessageLikeEventContent, RedactedStateEventContent,
2624
RoomAccountDataEventContent, StaticEventContent, StaticStateEventContent,
@@ -141,7 +139,7 @@ where
141139

142140
impl SyncEvent for PresenceEvent {
143141
const KIND: HandlerKind = HandlerKind::Presence;
144-
const TYPE: Option<&'static str> = Some(PresenceEventContent::TYPE);
142+
const TYPE: Option<&'static str> = None;
145143
}
146144

147145
impl SyncEvent for AnyGlobalAccountDataEvent {

crates/matrix-sdk/src/http_client/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ impl HttpClient {
174174
AuthScheme::AccessToken
175175
| AuthScheme::AccessTokenOptional
176176
| AuthScheme::AppserviceToken
177+
| AuthScheme::AppserviceTokenOptional
177178
| AuthScheme::None => {}
178179
AuthScheme::ServerSignatures => {
179180
return Err(HttpError::NotClientRequest);

crates/matrix-sdk/src/room/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,9 +3161,8 @@ impl Room {
31613161
/// # Errors
31623162
///
31633163
/// Returns an error if the room is not found or on rate limit
3164-
pub async fn report_room(&self, reason: Option<String>) -> Result<report_room::v3::Response> {
3165-
let mut request = report_room::v3::Request::new(self.inner.room_id().to_owned());
3166-
request.reason = reason;
3164+
pub async fn report_room(&self, reason: String) -> Result<report_room::v3::Response> {
3165+
let request = report_room::v3::Request::new(self.inner.room_id().to_owned(), reason);
31673166

31683167
Ok(self.client.send(request).await?)
31693168
}

crates/matrix-sdk/tests/integration/room/joined.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,5 +1407,5 @@ async fn test_report_room() {
14071407
let _response = client.sync_once(sync_settings).await.unwrap();
14081408
let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap();
14091409

1410-
room.report_room(Some(reason.to_owned())).await.unwrap();
1410+
room.report_room(reason.to_owned()).await.unwrap();
14111411
}

0 commit comments

Comments
 (0)