diff --git a/matrix_sdk_appservice/Cargo.toml b/matrix_sdk_appservice/Cargo.toml index 5230ff1e..59e34327 100644 --- a/matrix_sdk_appservice/Cargo.toml +++ b/matrix_sdk_appservice/Cargo.toml @@ -21,6 +21,7 @@ futures = "0.3" futures-util = "0.3" http = "0.2" regex = "1" +serde = "1.0.126" serde_yaml = "0.8" thiserror = "1.0" tracing = "0.1" @@ -28,6 +29,10 @@ url = "2" matrix-sdk = { version = "0.2", path = "../matrix_sdk", default-features = false, features = ["appservice", "native-tls"] } +[dependencies.ruma] +version = "0.1.2" +features = ["client-api-c", "appservice-api-s", "unstable-pre-spec"] + [dev-dependencies] env_logger = "0.8" mockito = "0.30" diff --git a/matrix_sdk_appservice/src/actix.rs b/matrix_sdk_appservice/src/actix.rs index 672f417a..7ee09183 100644 --- a/matrix_sdk_appservice/src/actix.rs +++ b/matrix_sdk_appservice/src/actix.rs @@ -29,7 +29,7 @@ use actix_web::{ }; use futures::Future; use futures_util::{TryFutureExt, TryStreamExt}; -use matrix_sdk::api_appservice as api; +use ruma::api::appservice as api; use crate::{error::Error, Appservice}; @@ -102,7 +102,7 @@ pub struct IncomingRequest { incoming: T, } -impl FromRequest for IncomingRequest { +impl FromRequest for IncomingRequest { type Error = Error; type Future = Pin>>>; type Config = (); @@ -145,7 +145,7 @@ impl FromRequest for IncomingRequest { let access_token = match request.uri().query() { Some(query) => { - let query: Vec<(String, String)> = matrix_sdk::urlencoded::from_str(query)?; + let query: Vec<(String, String)> = ruma::serde::urlencoded::from_str(query)?; query.into_iter().find(|(key, _)| key == "access_token").map(|(_, value)| value) } None => None, @@ -160,7 +160,7 @@ impl FromRequest for IncomingRequest { Ok(IncomingRequest { access_token, - incoming: matrix_sdk::IncomingRequest::try_from_http_request(request)?, + incoming: ruma::api::IncomingRequest::try_from_http_request(request)?, }) }) } diff --git a/matrix_sdk_appservice/src/error.rs b/matrix_sdk_appservice/src/error.rs index c42b3370..3b59bef0 100644 --- a/matrix_sdk_appservice/src/error.rs +++ b/matrix_sdk_appservice/src/error.rs @@ -32,10 +32,10 @@ pub enum Error { NoClientForLocalpart, #[error(transparent)] - HttpRequest(#[from] matrix_sdk::FromHttpRequestError), + HttpRequest(#[from] ruma::api::error::FromHttpRequestError), #[error(transparent)] - Identifier(#[from] matrix_sdk::identifiers::Error), + Identifier(#[from] ruma::identifiers::Error), #[error(transparent)] Http(#[from] http::Error), @@ -44,7 +44,7 @@ pub enum Error { Url(#[from] url::ParseError), #[error(transparent)] - Serde(#[from] matrix_sdk::SerdeError), + Serde(#[from] serde::de::value::Error), #[error(transparent)] Io(#[from] std::io::Error), diff --git a/matrix_sdk_appservice/src/lib.rs b/matrix_sdk_appservice/src/lib.rs index 7aab474b..2b27fb57 100644 --- a/matrix_sdk_appservice/src/lib.rs +++ b/matrix_sdk_appservice/src/lib.rs @@ -87,23 +87,24 @@ use std::{ use dashmap::DashMap; use http::Uri; -#[doc(inline)] -pub use matrix_sdk::api_appservice as api; -use matrix_sdk::{ - api::{ - error::ErrorKind, - r0::{ - account::register::{LoginType, Request as RegistrationRequest}, - uiaa::UiaaResponse, - }, - }, - api_appservice::Registration, - assign, - identifiers::{self, DeviceId, ServerNameBox, UserId}, - reqwest::Url, - Client, ClientConfig, EventHandler, FromHttpResponseError, HttpError, ServerError, Session, -}; +use matrix_sdk::{reqwest::Url, Client, ClientConfig, EventHandler, HttpError, Session}; use regex::Regex; +#[doc(inline)] +pub use ruma::api::appservice as api; +use ruma::{ + api::{ + appservice::Registration, + client::{ + error::ErrorKind, + r0::{ + account::register::{LoginType, Request as RegistrationRequest}, + uiaa::UiaaResponse, + }, + }, + error::{FromHttpResponseError, ServerError}, + }, + assign, identifiers, DeviceId, ServerNameBox, UserId, +}; use tracing::warn; #[cfg(feature = "actix")]