|
|
|
@ -1,5 +1,6 @@ |
|
|
|
use crate::{ |
|
|
|
use crate::{ |
|
|
|
client_server::{self, claim_keys_helper, get_keys_helper}, |
|
|
|
client_server::{self, claim_keys_helper, get_keys_helper}, |
|
|
|
|
|
|
|
database::ReadGuard, |
|
|
|
utils, ConduitResult, Database, Error, PduEvent, Result, Ruma, |
|
|
|
utils, ConduitResult, Database, Error, PduEvent, Result, Ruma, |
|
|
|
}; |
|
|
|
}; |
|
|
|
use get_profile_information::v1::ProfileField; |
|
|
|
use get_profile_information::v1::ProfileField; |
|
|
|
@ -431,9 +432,7 @@ pub async fn request_well_known( |
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))] |
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
pub fn get_server_version_route( |
|
|
|
pub fn get_server_version_route(db: ReadGuard) -> ConduitResult<get_server_version::v1::Response> { |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
|
|
|
|
) -> ConduitResult<get_server_version::v1::Response> { |
|
|
|
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
return Err(Error::bad_config("Federation is disabled.")); |
|
|
|
return Err(Error::bad_config("Federation is disabled.")); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -450,7 +449,7 @@ pub fn get_server_version_route( |
|
|
|
// Response type for this endpoint is Json because we need to calculate a signature for the response
|
|
|
|
// 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"))] |
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
pub fn get_server_keys_route(db: State<'_, Arc<Database>>) -> Json<String> { |
|
|
|
pub fn get_server_keys_route(db: ReadGuard) -> Json<String> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
// TODO: Use proper types
|
|
|
|
// TODO: Use proper types
|
|
|
|
return Json("Federation is disabled.".to_owned()); |
|
|
|
return Json("Federation is disabled.".to_owned()); |
|
|
|
@ -497,7 +496,7 @@ pub fn get_server_keys_route(db: State<'_, Arc<Database>>) -> Json<String> { |
|
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))] |
|
|
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
#[tracing::instrument(skip(db))] |
|
|
|
pub fn get_server_keys_deprecated_route(db: State<'_, Arc<Database>>) -> Json<String> { |
|
|
|
pub fn get_server_keys_deprecated_route(db: ReadGuard) -> Json<String> { |
|
|
|
get_server_keys_route(db) |
|
|
|
get_server_keys_route(db) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -507,7 +506,7 @@ pub fn get_server_keys_deprecated_route(db: State<'_, Arc<Database>>) -> Json<St |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn get_public_rooms_filtered_route( |
|
|
|
pub async fn get_public_rooms_filtered_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_public_rooms_filtered::v1::Request<'_>>, |
|
|
|
body: Ruma<get_public_rooms_filtered::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_public_rooms_filtered::v1::Response> { |
|
|
|
) -> ConduitResult<get_public_rooms_filtered::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -551,7 +550,7 @@ pub async fn get_public_rooms_filtered_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn get_public_rooms_route( |
|
|
|
pub async fn get_public_rooms_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_public_rooms::v1::Request<'_>>, |
|
|
|
body: Ruma<get_public_rooms::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_public_rooms::v1::Response> { |
|
|
|
) -> ConduitResult<get_public_rooms::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -595,7 +594,7 @@ pub async fn get_public_rooms_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn send_transaction_message_route( |
|
|
|
pub async fn send_transaction_message_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<send_transaction_message::v1::Request<'_>>, |
|
|
|
body: Ruma<send_transaction_message::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<send_transaction_message::v1::Response> { |
|
|
|
) -> ConduitResult<send_transaction_message::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1674,7 +1673,7 @@ pub(crate) fn append_incoming_pdu( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_event_route( |
|
|
|
pub fn get_event_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_event::v1::Request<'_>>, |
|
|
|
body: Ruma<get_event::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_event::v1::Response> { |
|
|
|
) -> ConduitResult<get_event::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1699,7 +1698,7 @@ pub fn get_event_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_missing_events_route( |
|
|
|
pub fn get_missing_events_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_missing_events::v1::Request<'_>>, |
|
|
|
body: Ruma<get_missing_events::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_missing_events::v1::Response> { |
|
|
|
) -> ConduitResult<get_missing_events::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1748,7 +1747,7 @@ pub fn get_missing_events_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_event_authorization_route( |
|
|
|
pub fn get_event_authorization_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_event_authorization::v1::Request<'_>>, |
|
|
|
body: Ruma<get_event_authorization::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_event_authorization::v1::Response> { |
|
|
|
) -> ConduitResult<get_event_authorization::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1792,7 +1791,7 @@ pub fn get_event_authorization_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_room_state_route( |
|
|
|
pub fn get_room_state_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_room_state::v1::Request<'_>>, |
|
|
|
body: Ruma<get_room_state::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_room_state::v1::Response> { |
|
|
|
) -> ConduitResult<get_room_state::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1855,7 +1854,7 @@ pub fn get_room_state_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_room_state_ids_route( |
|
|
|
pub fn get_room_state_ids_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_room_state_ids::v1::Request<'_>>, |
|
|
|
body: Ruma<get_room_state_ids::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_room_state_ids::v1::Response> { |
|
|
|
) -> ConduitResult<get_room_state_ids::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -1907,7 +1906,7 @@ pub fn get_room_state_ids_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn create_join_event_template_route( |
|
|
|
pub fn create_join_event_template_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<create_join_event_template::v1::Request<'_>>, |
|
|
|
body: Ruma<create_join_event_template::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<create_join_event_template::v1::Response> { |
|
|
|
) -> ConduitResult<create_join_event_template::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2076,7 +2075,7 @@ pub fn create_join_event_template_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn create_join_event_route( |
|
|
|
pub async fn create_join_event_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<create_join_event::v2::Request<'_>>, |
|
|
|
body: Ruma<create_join_event::v2::Request<'_>>, |
|
|
|
) -> ConduitResult<create_join_event::v2::Response> { |
|
|
|
) -> ConduitResult<create_join_event::v2::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2184,7 +2183,7 @@ pub async fn create_join_event_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn create_invite_route( |
|
|
|
pub async fn create_invite_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<create_invite::v2::Request>, |
|
|
|
body: Ruma<create_invite::v2::Request>, |
|
|
|
) -> ConduitResult<create_invite::v2::Response> { |
|
|
|
) -> ConduitResult<create_invite::v2::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2289,7 +2288,7 @@ pub async fn create_invite_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_devices_route( |
|
|
|
pub fn get_devices_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_devices::v1::Request<'_>>, |
|
|
|
body: Ruma<get_devices::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_devices::v1::Response> { |
|
|
|
) -> ConduitResult<get_devices::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2329,7 +2328,7 @@ pub fn get_devices_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_room_information_route( |
|
|
|
pub fn get_room_information_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_room_information::v1::Request<'_>>, |
|
|
|
body: Ruma<get_room_information::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_room_information::v1::Response> { |
|
|
|
) -> ConduitResult<get_room_information::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2357,7 +2356,7 @@ pub fn get_room_information_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_profile_information_route( |
|
|
|
pub fn get_profile_information_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_profile_information::v1::Request<'_>>, |
|
|
|
body: Ruma<get_profile_information::v1::Request<'_>>, |
|
|
|
) -> ConduitResult<get_profile_information::v1::Response> { |
|
|
|
) -> ConduitResult<get_profile_information::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2391,7 +2390,7 @@ pub fn get_profile_information_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub fn get_keys_route( |
|
|
|
pub fn get_keys_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<get_keys::v1::Request>, |
|
|
|
body: Ruma<get_keys::v1::Request>, |
|
|
|
) -> ConduitResult<get_keys::v1::Response> { |
|
|
|
) -> ConduitResult<get_keys::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
@ -2419,7 +2418,7 @@ pub fn get_keys_route( |
|
|
|
)] |
|
|
|
)] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
pub async fn claim_keys_route( |
|
|
|
pub async fn claim_keys_route( |
|
|
|
db: State<'_, Arc<Database>>, |
|
|
|
db: ReadGuard, |
|
|
|
body: Ruma<claim_keys::v1::Request>, |
|
|
|
body: Ruma<claim_keys::v1::Request>, |
|
|
|
) -> ConduitResult<claim_keys::v1::Response> { |
|
|
|
) -> ConduitResult<claim_keys::v1::Response> { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|