2021-06-12 15:04:28 +02:00
|
|
|
use std::ops::Deref;
|
2020-07-25 23:08:00 -04:00
|
|
|
|
2022-10-09 17:25:06 +02:00
|
|
|
use ruma::{api::client::uiaa::UiaaResponse, CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId};
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-16 22:39:49 -04:00
|
|
|
use crate::{service::appservice::RegistrationInfo, Error};
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2022-01-20 11:51:31 +01:00
|
|
|
mod axum;
|
2020-02-15 22:42:21 +01:00
|
|
|
|
2022-01-20 11:51:31 +01:00
|
|
|
/// Extractor for Ruma request structs
|
2022-04-06 21:31:29 +02:00
|
|
|
pub struct Ruma<T> {
|
|
|
|
pub body: T,
|
2022-10-09 17:25:06 +02:00
|
|
|
pub sender_user: Option<OwnedUserId>,
|
|
|
|
pub sender_device: Option<OwnedDeviceId>,
|
|
|
|
pub sender_servername: Option<OwnedServerName>,
|
2021-04-23 19:04:59 +02:00
|
|
|
// This is None when body is not a valid string
|
2021-05-04 19:03:18 +02:00
|
|
|
pub json_body: Option<CanonicalJsonValue>,
|
2024-04-16 22:39:49 -04:00
|
|
|
pub appservice_info: Option<RegistrationInfo>,
|
2020-03-28 18:50:02 +01:00
|
|
|
}
|
2020-03-28 23:08:59 +01:00
|
|
|
|
2022-04-06 21:31:29 +02:00
|
|
|
impl<T> Deref for Ruma<T> {
|
|
|
|
type Target = T;
|
2020-02-15 22:42:21 +01:00
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target { &self.body }
|
2020-03-28 18:50:02 +01:00
|
|
|
}
|
|
|
|
|
2021-06-30 09:52:01 +02:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct RumaResponse<T>(pub T);
|
|
|
|
|
|
|
|
impl<T> From<T> for RumaResponse<T> {
|
2020-06-09 15:13:17 +02:00
|
|
|
fn from(t: T) -> Self { Self(t) }
|
2020-02-18 22:07:57 +01:00
|
|
|
}
|
|
|
|
|
2021-06-30 09:52:01 +02:00
|
|
|
impl From<Error> for RumaResponse<UiaaResponse> {
|
|
|
|
fn from(t: Error) -> Self { t.to_response() }
|
|
|
|
}
|