mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-06-27 16:35:59 +00:00
Merge branch 'appservice-ping' into 'next'
feat(appservice): pinging See merge request famedly/conduit!738
This commit is contained in:
commit
244dbbe6dd
11 changed files with 126 additions and 45 deletions
40
Cargo.lock
generated
40
Cargo.lock
generated
|
@ -2190,7 +2190,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma"
|
name = "ruma"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"js_int",
|
"js_int",
|
||||||
|
@ -2201,7 +2201,6 @@ dependencies = [
|
||||||
"ruma-events",
|
"ruma-events",
|
||||||
"ruma-federation-api",
|
"ruma-federation-api",
|
||||||
"ruma-push-gateway-api",
|
"ruma-push-gateway-api",
|
||||||
"ruma-server-util",
|
|
||||||
"ruma-signatures",
|
"ruma-signatures",
|
||||||
"ruma-state-res",
|
"ruma-state-res",
|
||||||
"web-time",
|
"web-time",
|
||||||
|
@ -2210,7 +2209,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-appservice-api"
|
name = "ruma-appservice-api"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -2222,7 +2221,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-client-api"
|
name = "ruma-client-api"
|
||||||
version = "0.20.1"
|
version = "0.20.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"assign",
|
"assign",
|
||||||
|
@ -2245,7 +2244,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-common"
|
name = "ruma-common"
|
||||||
version = "0.15.1"
|
version = "0.15.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
@ -2276,7 +2275,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-events"
|
name = "ruma-events"
|
||||||
version = "0.30.1"
|
version = "0.30.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as_variant",
|
"as_variant",
|
||||||
"indexmap 2.2.6",
|
"indexmap 2.2.6",
|
||||||
|
@ -2299,10 +2298,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-federation-api"
|
name = "ruma-federation-api"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"headers",
|
||||||
"http 1.1.0",
|
"http 1.1.0",
|
||||||
|
"http-auth",
|
||||||
"httparse",
|
"httparse",
|
||||||
"js_int",
|
"js_int",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2312,12 +2313,14 @@ dependencies = [
|
||||||
"ruma-events",
|
"ruma-events",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"thiserror 2.0.11",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-identifiers-validation"
|
name = "ruma-identifiers-validation"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"thiserror 2.0.11",
|
"thiserror 2.0.11",
|
||||||
|
@ -2326,7 +2329,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-macros"
|
name = "ruma-macros"
|
||||||
version = "0.15.1"
|
version = "0.15.1"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
|
@ -2341,7 +2344,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-push-gateway-api"
|
name = "ruma-push-gateway-api"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
@ -2350,23 +2353,10 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ruma-server-util"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
|
||||||
dependencies = [
|
|
||||||
"headers",
|
|
||||||
"http 1.1.0",
|
|
||||||
"http-auth",
|
|
||||||
"ruma-common",
|
|
||||||
"thiserror 2.0.11",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-signatures"
|
name = "ruma-signatures"
|
||||||
version = "0.17.0"
|
version = "0.17.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
@ -2382,7 +2372,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruma-state-res"
|
name = "ruma-state-res"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/ruma/ruma.git#9e6099161d4ed295e694fa0d5de2b28a23840a4f"
|
source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js_int",
|
"js_int",
|
||||||
"ruma-common",
|
"ruma-common",
|
||||||
|
|
|
@ -160,7 +160,6 @@ features = [
|
||||||
"push-gateway-api-c",
|
"push-gateway-api-c",
|
||||||
"rand",
|
"rand",
|
||||||
"ring-compat",
|
"ring-compat",
|
||||||
"server-util",
|
|
||||||
"state-res",
|
"state-res",
|
||||||
"unstable-msc2448",
|
"unstable-msc2448",
|
||||||
"unstable-msc3575",
|
"unstable-msc3575",
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use crate::{services, utils, Error, Result};
|
use crate::{services, utils, Error, Result, MATRIX_VERSIONS};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use ruma::api::{
|
use ruma::api::{appservice::Registration, IncomingResponse, OutgoingRequest, SendAccessToken};
|
||||||
appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
|
||||||
};
|
|
||||||
use std::{fmt::Debug, mem, time::Duration};
|
use std::{fmt::Debug, mem, time::Duration};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
|
@ -30,7 +28,7 @@ where
|
||||||
.try_into_http_request::<BytesMut>(
|
.try_into_http_request::<BytesMut>(
|
||||||
&destination,
|
&destination,
|
||||||
SendAccessToken::IfRequired(hs_token),
|
SendAccessToken::IfRequired(hs_token),
|
||||||
&[MatrixVersion::V1_0],
|
MATRIX_VERSIONS,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.map(|body| body.freeze());
|
.map(|body| body.freeze());
|
||||||
|
|
80
src/api/client_server/appservice.rs
Normal file
80
src/api/client_server/appservice.rs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use ruma::api::{
|
||||||
|
appservice::ping::send_ping,
|
||||||
|
client::{appservice::request_ping, error::ErrorKind},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{api::appservice_server, Error, Result, Ruma};
|
||||||
|
|
||||||
|
/// # `POST /_matrix/client/v1/appservice/{appserviceId}/ping`
|
||||||
|
///
|
||||||
|
/// Allows an appservice to check whether the server and
|
||||||
|
/// appservice can connect, and how fast their connection is
|
||||||
|
pub async fn ping_appservice_route(
|
||||||
|
body: Ruma<request_ping::v1::Request>,
|
||||||
|
) -> Result<request_ping::v1::Response> {
|
||||||
|
let Ruma::<request_ping::v1::Request> {
|
||||||
|
appservice_info,
|
||||||
|
body,
|
||||||
|
..
|
||||||
|
} = body;
|
||||||
|
|
||||||
|
let registration = appservice_info
|
||||||
|
.expect("Only appservices can call this endpoint")
|
||||||
|
.registration;
|
||||||
|
|
||||||
|
if registration.id != body.appservice_id {
|
||||||
|
return Err(Error::BadRequest(
|
||||||
|
ErrorKind::forbidden(),
|
||||||
|
"Appservice ID specified in path does not match the requesting access token",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if registration.url.is_some() {
|
||||||
|
let start = Instant::now();
|
||||||
|
let response = appservice_server::send_request(
|
||||||
|
registration,
|
||||||
|
send_ping::v1::Request {
|
||||||
|
transaction_id: body.transaction_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let elapsed = start.elapsed();
|
||||||
|
|
||||||
|
if let Err(error) = response {
|
||||||
|
Err(match error {
|
||||||
|
Error::ReqwestError { source } => {
|
||||||
|
if source.is_timeout() {
|
||||||
|
Error::BadRequest(
|
||||||
|
ErrorKind::ConnectionTimeout,
|
||||||
|
"Connection to appservice timed-out",
|
||||||
|
)
|
||||||
|
} else if let Some(status_code) = source.status() {
|
||||||
|
Error::BadRequest(
|
||||||
|
ErrorKind::BadStatus {
|
||||||
|
status: Some(status_code),
|
||||||
|
body: Some(source.to_string()),
|
||||||
|
},
|
||||||
|
"Ping returned error status",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Error::BadRequest(ErrorKind::ConnectionFailed, "Failed to ping appservice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Error::BadServerResponse(_) => Error::BadRequest(
|
||||||
|
ErrorKind::ConnectionFailed,
|
||||||
|
"Recieved invalid response from appservice",
|
||||||
|
),
|
||||||
|
e => e,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Ok(request_ping::v1::Response::new(elapsed))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(Error::BadRequest(
|
||||||
|
ErrorKind::UrlNotSet,
|
||||||
|
"Appservice doesn't have a URL configured",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
mod account;
|
mod account;
|
||||||
mod alias;
|
mod alias;
|
||||||
|
mod appservice;
|
||||||
mod backup;
|
mod backup;
|
||||||
mod capabilities;
|
mod capabilities;
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -37,6 +38,7 @@ mod well_known;
|
||||||
|
|
||||||
pub use account::*;
|
pub use account::*;
|
||||||
pub use alias::*;
|
pub use alias::*;
|
||||||
|
pub use appservice::*;
|
||||||
pub use backup::*;
|
pub use backup::*;
|
||||||
pub use capabilities::*;
|
pub use capabilities::*;
|
||||||
pub use config::*;
|
pub use config::*;
|
||||||
|
|
|
@ -15,8 +15,10 @@ use axum_extra::{
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
use http::{Request, StatusCode};
|
use http::{Request, StatusCode};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{client::error::ErrorKind, AuthScheme, IncomingRequest, OutgoingResponse},
|
api::{
|
||||||
server_util::authorization::XMatrix,
|
client::error::ErrorKind, federation::authentication::XMatrix, AuthScheme, IncomingRequest,
|
||||||
|
OutgoingResponse,
|
||||||
|
},
|
||||||
CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, UserId,
|
CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, UserId,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -110,7 +112,10 @@ where
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(AuthScheme::AccessToken, Token::Appservice(info)) => {
|
(
|
||||||
|
AuthScheme::AccessToken | AuthScheme::AppserviceToken,
|
||||||
|
Token::Appservice(info),
|
||||||
|
) => {
|
||||||
let user_id = query_params
|
let user_id = query_params
|
||||||
.user_id
|
.user_id
|
||||||
.map_or_else(
|
.map_or_else(
|
||||||
|
@ -144,11 +149,11 @@ where
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
AuthScheme::None
|
AuthScheme::None
|
||||||
| AuthScheme::AppserviceToken
|
| AuthScheme::AppserviceTokenOptional
|
||||||
| AuthScheme::AccessTokenOptional,
|
| AuthScheme::AccessTokenOptional,
|
||||||
Token::Appservice(info),
|
Token::Appservice(info),
|
||||||
) => (None, None, None, Some(*info)),
|
) => (None, None, None, Some(*info)),
|
||||||
(AuthScheme::AccessToken, Token::None) => {
|
(AuthScheme::AppserviceToken | AuthScheme::AccessToken, Token::None) => {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::MissingToken,
|
ErrorKind::MissingToken,
|
||||||
"Missing access token.",
|
"Missing access token.",
|
||||||
|
@ -287,7 +292,7 @@ where
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
AuthScheme::None
|
AuthScheme::None
|
||||||
| AuthScheme::AppserviceToken
|
| AuthScheme::AppserviceTokenOptional
|
||||||
| AuthScheme::AccessTokenOptional,
|
| AuthScheme::AccessTokenOptional,
|
||||||
Token::None,
|
Token::None,
|
||||||
) => (None, None, None, None),
|
) => (None, None, None, None),
|
||||||
|
@ -297,7 +302,10 @@ where
|
||||||
"Only server signatures should be used on this endpoint.",
|
"Only server signatures should be used on this endpoint.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
(AuthScheme::AppserviceToken, Token::User(_)) => {
|
(
|
||||||
|
AuthScheme::AppserviceToken | AuthScheme::AppserviceTokenOptional,
|
||||||
|
Token::User(_),
|
||||||
|
) => {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
ErrorKind::Unauthorized,
|
ErrorKind::Unauthorized,
|
||||||
"Only appservice access tokens should be used on this endpoint.",
|
"Only appservice access tokens should be used on this endpoint.",
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
media::FileMeta,
|
media::FileMeta,
|
||||||
pdu::{gen_event_id_canonical_json, PduBuilder},
|
pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||||
},
|
},
|
||||||
services, utils, Error, PduEvent, Result, Ruma,
|
services, utils, Error, PduEvent, Result, Ruma, MATRIX_VERSIONS,
|
||||||
};
|
};
|
||||||
use axum::{response::IntoResponse, Json};
|
use axum::{response::IntoResponse, Json};
|
||||||
use axum_extra::headers::{CacheControl, Header};
|
use axum_extra::headers::{CacheControl, Header};
|
||||||
|
@ -44,8 +44,7 @@ use ruma::{
|
||||||
send_transaction_message,
|
send_transaction_message,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest, OutgoingResponse,
|
EndpointError, IncomingResponse, OutgoingRequest, OutgoingResponse, SendAccessToken,
|
||||||
SendAccessToken,
|
|
||||||
},
|
},
|
||||||
directory::{Filter, RoomNetwork},
|
directory::{Filter, RoomNetwork},
|
||||||
events::{
|
events::{
|
||||||
|
@ -215,7 +214,7 @@ where
|
||||||
.try_into_http_request::<Vec<u8>>(
|
.try_into_http_request::<Vec<u8>>(
|
||||||
&actual_destination_str,
|
&actual_destination_str,
|
||||||
SendAccessToken::IfRequired(""),
|
SendAccessToken::IfRequired(""),
|
||||||
&[MatrixVersion::V1_11],
|
MATRIX_VERSIONS,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
warn!(
|
warn!(
|
||||||
|
|
|
@ -13,10 +13,12 @@ use std::sync::RwLock;
|
||||||
pub use api::ruma_wrapper::{Ruma, RumaResponse};
|
pub use api::ruma_wrapper::{Ruma, RumaResponse};
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use database::KeyValueDatabase;
|
pub use database::KeyValueDatabase;
|
||||||
|
use ruma::api::MatrixVersion;
|
||||||
pub use service::{pdu::PduEvent, Services};
|
pub use service::{pdu::PduEvent, Services};
|
||||||
pub use utils::error::{Error, Result};
|
pub use utils::error::{Error, Result};
|
||||||
|
|
||||||
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
|
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
|
||||||
|
pub const MATRIX_VERSIONS: &[MatrixVersion] = &[MatrixVersion::V1_13];
|
||||||
|
|
||||||
pub fn services() -> &'static Services {
|
pub fn services() -> &'static Services {
|
||||||
SERVICES
|
SERVICES
|
||||||
|
|
|
@ -279,6 +279,7 @@ async fn unrecognized_method(
|
||||||
|
|
||||||
fn routes(config: &Config) -> Router {
|
fn routes(config: &Config) -> Router {
|
||||||
let router = Router::new()
|
let router = Router::new()
|
||||||
|
.ruma_route(client_server::ping_appservice_route)
|
||||||
.ruma_route(client_server::get_supported_versions_route)
|
.ruma_route(client_server::get_supported_versions_route)
|
||||||
.ruma_route(client_server::get_register_available_route)
|
.ruma_route(client_server::get_register_available_route)
|
||||||
.ruma_route(client_server::register_route)
|
.ruma_route(client_server::register_route)
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod data;
|
||||||
pub use data::Data;
|
pub use data::Data;
|
||||||
use ruma::{events::AnySyncTimelineEvent, push::PushConditionPowerLevelsCtx};
|
use ruma::{events::AnySyncTimelineEvent, push::PushConditionPowerLevelsCtx};
|
||||||
|
|
||||||
use crate::{services, Error, PduEvent, Result};
|
use crate::{services, Error, PduEvent, Result, MATRIX_VERSIONS};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
|
@ -11,7 +11,7 @@ use ruma::{
|
||||||
self,
|
self,
|
||||||
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
||||||
},
|
},
|
||||||
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
IncomingResponse, OutgoingRequest, SendAccessToken,
|
||||||
},
|
},
|
||||||
events::{room::power_levels::RoomPowerLevelsEventContent, StateEventType, TimelineEventType},
|
events::{room::power_levels::RoomPowerLevelsEventContent, StateEventType, TimelineEventType},
|
||||||
push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak},
|
push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak},
|
||||||
|
@ -58,7 +58,7 @@ impl Service {
|
||||||
.try_into_http_request::<BytesMut>(
|
.try_into_http_request::<BytesMut>(
|
||||||
&destination,
|
&destination,
|
||||||
SendAccessToken::IfRequired(""),
|
SendAccessToken::IfRequired(""),
|
||||||
&[MatrixVersion::V1_0],
|
MATRIX_VERSIONS,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
warn!("Failed to find destination {}: {}", destination, e);
|
warn!("Failed to find destination {}: {}", destination, e);
|
||||||
|
|
|
@ -122,6 +122,8 @@ impl Error {
|
||||||
LimitExceeded { .. } => StatusCode::TOO_MANY_REQUESTS,
|
LimitExceeded { .. } => StatusCode::TOO_MANY_REQUESTS,
|
||||||
UserDeactivated => StatusCode::FORBIDDEN,
|
UserDeactivated => StatusCode::FORBIDDEN,
|
||||||
TooLarge => StatusCode::PAYLOAD_TOO_LARGE,
|
TooLarge => StatusCode::PAYLOAD_TOO_LARGE,
|
||||||
|
ConnectionTimeout => StatusCode::GATEWAY_TIMEOUT,
|
||||||
|
BadStatus { .. } | ConnectionFailed => StatusCode::BAD_GATEWAY,
|
||||||
_ => StatusCode::BAD_REQUEST,
|
_ => StatusCode::BAD_REQUEST,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue