Skip to content

Commit 4053f69

Browse files
Daniel SalinasDaniel Salinas
authored andcommitted
Merge branch 'main' into rework_matrix_sdk_ffi_with_features
2 parents 62f3e08 + 9f8824b commit 4053f69

File tree

71 files changed

+3362
-995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3362
-995
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ jobs:
246246
components: clippy
247247

248248
- name: Install wasm-pack
249-
uses: qmaru/wasm-pack-action@v0.5.0
249+
uses: qmaru/wasm-pack-action@v0.5.1
250250
if: '!matrix.check_only'
251251
with:
252252
version: v0.10.3

.github/workflows/detect-long-path.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- name: Check for changed files
2222
id: changed-files
23-
uses: tj-actions/changed-files@115870536a85eaf050e369291c7895748ff12aea
23+
uses: tj-actions/changed-files@v46.0.5
2424
- name: Detect long path
2525
env:
2626
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} # ignore the deleted files

bindings/matrix-sdk-crypto-ffi/src/dehydrated_devices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{mem::ManuallyDrop, sync::Arc};
22

3+
use matrix_sdk_common::executor::Handle;
34
use matrix_sdk_crypto::{
45
dehydrated_devices::{
56
DehydratedDevice as InnerDehydratedDevice, DehydratedDevices as InnerDehydratedDevices,
@@ -9,7 +10,6 @@ use matrix_sdk_crypto::{
910
};
1011
use ruma::{api::client::dehydrated_device, events::AnyToDeviceEvent, serde::Raw, OwnedDeviceId};
1112
use serde_json::json;
12-
use tokio::runtime::Handle;
1313

1414
use crate::{CryptoStoreError, DehydratedDeviceKey};
1515

bindings/matrix-sdk-crypto-ffi/src/verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::sync::Arc;
22

33
use futures_util::{Stream, StreamExt};
4+
use matrix_sdk_common::executor::Handle;
45
use matrix_sdk_crypto::{
56
matrix_sdk_qrcode::QrVerificationData, CancelInfo as RustCancelInfo, QrVerification as InnerQr,
67
QrVerificationState, Sas as InnerSas, SasState as RustSasState,
78
Verification as InnerVerification, VerificationRequest as InnerVerificationRequest,
89
VerificationRequestState as RustVerificationRequestState,
910
};
1011
use ruma::events::key::verification::VerificationMethod;
11-
use tokio::runtime::Handle;
1212
use vodozemac::{base64_decode, base64_encode};
1313

1414
use crate::{CryptoStoreError, OutgoingVerificationRequest, SignatureUploadRequest};

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
use std::{collections::HashMap, error::Error, fmt, fmt::Display, time::SystemTime};
1+
use std::{collections::HashMap, error::Error, fmt, fmt::Display};
22

33
use matrix_sdk::{
4-
authentication::oauth::OAuthError, encryption::CryptoStoreError, event_cache::EventCacheError,
5-
reqwest, room::edit::EditError, send_queue::RoomSendQueueError, HttpError, IdParseError,
6-
NotificationSettingsError as SdkNotificationSettingsError,
4+
authentication::oauth::OAuthError,
5+
encryption::{identities::RequestVerificationError, CryptoStoreError},
6+
event_cache::EventCacheError,
7+
reqwest,
8+
room::edit::EditError,
9+
send_queue::RoomSendQueueError,
10+
HttpError, IdParseError, NotificationSettingsError as SdkNotificationSettingsError,
711
QueueWedgeError as SdkQueueWedgeError, StoreError,
812
};
913
use matrix_sdk_ui::{encryption_sync_service, notification_client, sync_service, timeline};
10-
use ruma::api::client::error::{ErrorBody, ErrorKind as RumaApiErrorKind, RetryAfter};
14+
use ruma::{
15+
api::client::error::{ErrorBody, ErrorKind as RumaApiErrorKind, RetryAfter},
16+
MilliSecondsSinceUnixEpoch,
17+
};
1118
use tracing::warn;
1219
use uniffi::UnexpectedUniFFICallbackError;
1320

@@ -198,6 +205,12 @@ impl From<FocusEventError> for ClientError {
198205
}
199206
}
200207

208+
impl From<RequestVerificationError> for ClientError {
209+
fn from(e: RequestVerificationError) -> Self {
210+
Self::from_err(e)
211+
}
212+
}
213+
201214
/// Bindings version of the sdk type replacing OwnedUserId/DeviceIds with simple
202215
/// String.
203216
///
@@ -749,7 +762,9 @@ impl TryFrom<RumaApiErrorKind> for ErrorKind {
749762
let retry_after_ms = match retry_after {
750763
Some(RetryAfter::Delay(duration)) => Some(duration.as_millis() as u64),
751764
Some(RetryAfter::DateTime(system_time)) => {
752-
let duration = system_time.duration_since(SystemTime::now()).ok();
765+
let duration = MilliSecondsSinceUnixEpoch::now()
766+
.to_system_time()
767+
.and_then(|now| system_time.duration_since(now).ok());
753768
duration.map(|duration| duration.as_millis() as u64)
754769
}
755770
None => None,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ impl TracingConfiguration {
410410
sentry::ClientOptions {
411411
traces_sample_rate: 0.0,
412412
attach_stacktrace: true,
413+
release: Some(env!("VERGEN_GIT_SHA").into()),
413414
..sentry::ClientOptions::default()
414415
},
415416
));

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,18 +828,31 @@ impl Room {
828828

829829
/// Store the given `ComposerDraft` in the state store using the current
830830
/// room id, as identifier.
831-
pub async fn save_composer_draft(&self, draft: ComposerDraft) -> Result<(), ClientError> {
832-
Ok(self.inner.save_composer_draft(draft.try_into()?).await?)
831+
pub async fn save_composer_draft(
832+
&self,
833+
draft: ComposerDraft,
834+
thread_root: Option<String>,
835+
) -> Result<(), ClientError> {
836+
let thread_root = thread_root.map(EventId::parse).transpose()?;
837+
Ok(self.inner.save_composer_draft(draft.try_into()?, thread_root.as_deref()).await?)
833838
}
834839

835840
/// Retrieve the `ComposerDraft` stored in the state store for this room.
836-
pub async fn load_composer_draft(&self) -> Result<Option<ComposerDraft>, ClientError> {
837-
Ok(self.inner.load_composer_draft().await?.map(Into::into))
841+
pub async fn load_composer_draft(
842+
&self,
843+
thread_root: Option<String>,
844+
) -> Result<Option<ComposerDraft>, ClientError> {
845+
let thread_root = thread_root.map(EventId::parse).transpose()?;
846+
Ok(self.inner.load_composer_draft(thread_root.as_deref()).await?.map(Into::into))
838847
}
839848

840849
/// Remove the `ComposerDraft` stored in the state store for this room.
841-
pub async fn clear_composer_draft(&self) -> Result<(), ClientError> {
842-
Ok(self.inner.clear_composer_draft().await?)
850+
pub async fn clear_composer_draft(
851+
&self,
852+
thread_root: Option<String>,
853+
) -> Result<(), ClientError> {
854+
let thread_root = thread_root.map(EventId::parse).transpose()?;
855+
Ok(self.inner.clear_composer_draft(thread_root.as_deref()).await?)
843856
}
844857

845858
/// Edit an event given its event id.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mod sys {
3939
mod sys {
4040
use std::future::Future;
4141

42-
use crate::executor::{spawn, JoinHandle};
42+
use matrix_sdk_common::executor::{spawn, JoinHandle};
4343

4444
/// A dummy guard that does nothing when dropped.
4545
/// This is used for the Wasm implementation to match

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,8 @@ impl SessionVerificationController {
116116
/// Request verification for the current device
117117
pub async fn request_device_verification(&self) -> Result<(), ClientError> {
118118
let methods = vec![VerificationMethod::SasV1];
119-
let verification_request = self
120-
.user_identity
121-
.request_verification_with_methods(methods)
122-
.await
123-
.map_err(anyhow::Error::from)?;
119+
let verification_request =
120+
self.user_identity.request_verification_with_methods(methods).await?;
124121

125122
self.set_ongoing_verification_request(verification_request)
126123
}
@@ -141,10 +138,7 @@ impl SessionVerificationController {
141138

142139
let methods = vec![VerificationMethod::SasV1];
143140

144-
let verification_request = user_identity
145-
.request_verification_with_methods(methods)
146-
.await
147-
.map_err(anyhow::Error::from)?;
141+
let verification_request = user_identity.request_verification_with_methods(methods).await?;
148142

149143
self.set_ongoing_verification_request(verification_request)
150144
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use tokio::task::JoinHandle;
1+
use matrix_sdk_common::executor::JoinHandle;
22
use tracing::debug;
33

44
/// A task handle is a way to keep the handle a task running by itself in

0 commit comments

Comments
 (0)