|
|
|
|
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
|
|
|
|
use crate::{ |
|
|
|
|
client_server::{self, claim_keys_helper, get_keys_helper}, |
|
|
|
|
database::ReadGuard, |
|
|
|
|
database::DatabaseGuard, |
|
|
|
|
utils, ConduitResult, Database, Error, PduEvent, Result, Ruma, |
|
|
|
|
}; |
|
|
|
|
use get_profile_information::v1::ProfileField; |
|
|
|
|
@ -432,7 +432,9 @@ pub async fn request_well_known(
@@ -432,7 +432,9 @@ pub async fn request_well_known(
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))] |
|
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
|
pub fn get_server_version_route(db: ReadGuard) -> ConduitResult<get_server_version::v1::Response> { |
|
|
|
|
pub fn get_server_version_route( |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
) -> ConduitResult<get_server_version::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
return Err(Error::bad_config("Federation is disabled.")); |
|
|
|
|
} |
|
|
|
|
@ -449,7 +451,7 @@ pub fn get_server_version_route(db: ReadGuard) -> ConduitResult<get_server_versi
@@ -449,7 +451,7 @@ pub fn get_server_version_route(db: ReadGuard) -> ConduitResult<get_server_versi
|
|
|
|
|
// Response type for this endpoint is Json because we need to calculate a signature for the response
|
|
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))] |
|
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
|
pub fn get_server_keys_route(db: ReadGuard) -> Json<String> { |
|
|
|
|
pub fn get_server_keys_route(db: DatabaseGuard) -> Json<String> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
// TODO: Use proper types
|
|
|
|
|
return Json("Federation is disabled.".to_owned()); |
|
|
|
|
@ -496,7 +498,7 @@ pub fn get_server_keys_route(db: ReadGuard) -> Json<String> {
@@ -496,7 +498,7 @@ pub fn get_server_keys_route(db: ReadGuard) -> Json<String> {
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))] |
|
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
|
pub fn get_server_keys_deprecated_route(db: ReadGuard) -> Json<String> { |
|
|
|
|
pub fn get_server_keys_deprecated_route(db: DatabaseGuard) -> Json<String> { |
|
|
|
|
get_server_keys_route(db) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -506,7 +508,7 @@ pub fn get_server_keys_deprecated_route(db: ReadGuard) -> Json<String> {
@@ -506,7 +508,7 @@ pub fn get_server_keys_deprecated_route(db: ReadGuard) -> Json<String> {
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn get_public_rooms_filtered_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_public_rooms_filtered::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_public_rooms_filtered::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -550,7 +552,7 @@ pub async fn get_public_rooms_filtered_route(
@@ -550,7 +552,7 @@ pub async fn get_public_rooms_filtered_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn get_public_rooms_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_public_rooms::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_public_rooms::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -594,7 +596,7 @@ pub async fn get_public_rooms_route(
@@ -594,7 +596,7 @@ pub async fn get_public_rooms_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn send_transaction_message_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<send_transaction_message::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<send_transaction_message::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1675,7 +1677,7 @@ pub(crate) fn append_incoming_pdu(
@@ -1675,7 +1677,7 @@ pub(crate) fn append_incoming_pdu(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_event_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_event::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_event::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1700,7 +1702,7 @@ pub fn get_event_route(
@@ -1700,7 +1702,7 @@ pub fn get_event_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_missing_events_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_missing_events::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_missing_events::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1749,7 +1751,7 @@ pub fn get_missing_events_route(
@@ -1749,7 +1751,7 @@ pub fn get_missing_events_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_event_authorization_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_event_authorization::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_event_authorization::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1793,7 +1795,7 @@ pub fn get_event_authorization_route(
@@ -1793,7 +1795,7 @@ pub fn get_event_authorization_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_room_state_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_room_state::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_room_state::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1856,7 +1858,7 @@ pub fn get_room_state_route(
@@ -1856,7 +1858,7 @@ pub fn get_room_state_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_room_state_ids_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_room_state_ids::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_room_state_ids::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -1908,7 +1910,7 @@ pub fn get_room_state_ids_route(
@@ -1908,7 +1910,7 @@ pub fn get_room_state_ids_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn create_join_event_template_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<create_join_event_template::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<create_join_event_template::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2077,7 +2079,7 @@ pub fn create_join_event_template_route(
@@ -2077,7 +2079,7 @@ pub fn create_join_event_template_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn create_join_event_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<create_join_event::v2::Request<'_>>, |
|
|
|
|
) -> ConduitResult<create_join_event::v2::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2187,7 +2189,7 @@ pub async fn create_join_event_route(
@@ -2187,7 +2189,7 @@ pub async fn create_join_event_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn create_invite_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<create_invite::v2::Request>, |
|
|
|
|
) -> ConduitResult<create_invite::v2::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2294,7 +2296,7 @@ pub async fn create_invite_route(
@@ -2294,7 +2296,7 @@ pub async fn create_invite_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_devices_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_devices::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_devices::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2334,7 +2336,7 @@ pub fn get_devices_route(
@@ -2334,7 +2336,7 @@ pub fn get_devices_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_room_information_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_room_information::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_room_information::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2362,7 +2364,7 @@ pub fn get_room_information_route(
@@ -2362,7 +2364,7 @@ pub fn get_room_information_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_profile_information_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_profile_information::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_profile_information::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2396,7 +2398,7 @@ pub fn get_profile_information_route(
@@ -2396,7 +2398,7 @@ pub fn get_profile_information_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn get_keys_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<get_keys::v1::Request>, |
|
|
|
|
) -> ConduitResult<get_keys::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
@ -2426,7 +2428,7 @@ pub async fn get_keys_route(
@@ -2426,7 +2428,7 @@ pub async fn get_keys_route(
|
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub async fn claim_keys_route( |
|
|
|
|
db: ReadGuard, |
|
|
|
|
db: DatabaseGuard, |
|
|
|
|
body: Ruma<claim_keys::v1::Request>, |
|
|
|
|
) -> ConduitResult<claim_keys::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
|