Skip to content

Commit 93e2549

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

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
@@ -2442,9 +2442,7 @@ impl TryFrom<AllowRule> for RumaAllowRule {
24422442
match value {
24432443
AllowRule::RoomMembership { room_id } => {
24442444
let room_id = RoomId::parse(room_id)?;
2445-
Ok(Self::RoomMembership(ruma::events::room::join_rules::RoomMembership::new(
2446-
room_id,
2447-
)))
2445+
Ok(Self::RoomMembership(ruma::room::RoomMembership::new(room_id)))
24482446
}
24492447
AllowRule::Custom { json } => Ok(Self::_Custom(Box::new(serde_json::from_str(&json)?))),
24502448
}

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
@@ -183,6 +183,7 @@ impl HttpClient {
183183
AuthScheme::AccessToken
184184
| AuthScheme::AccessTokenOptional
185185
| AuthScheme::AppserviceToken
186+
| AuthScheme::AppserviceTokenOptional
186187
| AuthScheme::None => {}
187188
AuthScheme::ServerSignatures => {
188189
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
@@ -3157,9 +3157,8 @@ impl Room {
31573157
/// # Errors
31583158
///
31593159
/// Returns an error if the room is not found or on rate limit
3160-
pub async fn report_room(&self, reason: Option<String>) -> Result<report_room::v3::Response> {
3161-
let mut request = report_room::v3::Request::new(self.inner.room_id().to_owned());
3162-
request.reason = reason;
3160+
pub async fn report_room(&self, reason: String) -> Result<report_room::v3::Response> {
3161+
let request = report_room::v3::Request::new(self.inner.room_id().to_owned(), reason);
31633162

31643163
Ok(self.client.send(request).await?)
31653164
}

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

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

1384-
room.report_room(Some(reason.to_owned())).await.unwrap();
1384+
room.report_room(reason.to_owned()).await.unwrap();
13851385
}

0 commit comments

Comments
 (0)