mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-14 21:46:29 +03:00
replace ReadGuard with DatabaseGuard
This commit is contained in:
parent
3a76fda92b
commit
bcfea98457
28 changed files with 162 additions and 153 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::{collections::BTreeMap, convert::TryInto};
|
||||
|
||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use log::info;
|
||||
use ruma::{
|
||||
api::client::{
|
||||
|
@ -42,7 +42,7 @@ const GUEST_NAME_LENGTH: usize = 10;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_register_available_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_username_availability::Request<'_>>,
|
||||
) -> ConduitResult<get_username_availability::Response> {
|
||||
// Validate user id
|
||||
|
@ -85,7 +85,7 @@ pub async fn get_register_available_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn register_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<register::Request<'_>>,
|
||||
) -> ConduitResult<register::Response> {
|
||||
if !db.globals.allow_registration() && !body.from_appservice {
|
||||
|
@ -496,7 +496,7 @@ pub async fn register_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn change_password_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<change_password::Request<'_>>,
|
||||
) -> ConduitResult<change_password::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -588,7 +588,7 @@ pub async fn whoami_route(body: Ruma<whoami::Request>) -> ConduitResult<whoami::
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn deactivate_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<deactivate::Request<'_>>,
|
||||
) -> ConduitResult<deactivate::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Ruma};
|
||||
use regex::Regex;
|
||||
use ruma::{
|
||||
api::{
|
||||
|
@ -21,7 +21,7 @@ use rocket::{delete, get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_alias_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_alias::Request<'_>>,
|
||||
) -> ConduitResult<create_alias::Response> {
|
||||
if db.rooms.id_from_alias(&body.room_alias)?.is_some() {
|
||||
|
@ -42,7 +42,7 @@ pub async fn create_alias_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_alias_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_alias::Request<'_>>,
|
||||
) -> ConduitResult<delete_alias::Response> {
|
||||
db.rooms.set_alias(&body.room_alias, None, &db.globals)?;
|
||||
|
@ -58,7 +58,7 @@ pub async fn delete_alias_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_alias_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_alias::Request<'_>>,
|
||||
) -> ConduitResult<get_alias::Response> {
|
||||
get_alias_helper(&db, &body.room_alias).await
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::api::client::{
|
||||
error::ErrorKind,
|
||||
r0::backup::{
|
||||
|
@ -18,7 +18,7 @@ use rocket::{delete, get, post, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_backup_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_backup::Request>,
|
||||
) -> ConduitResult<create_backup::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -37,7 +37,7 @@ pub async fn create_backup_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_backup_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<update_backup::Request<'_>>,
|
||||
) -> ConduitResult<update_backup::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -55,7 +55,7 @@ pub async fn update_backup_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_latest_backup_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_latest_backup::Request>,
|
||||
) -> ConduitResult<get_latest_backup::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -83,7 +83,7 @@ pub async fn get_latest_backup_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_backup::Request<'_>>,
|
||||
) -> ConduitResult<get_backup::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -110,7 +110,7 @@ pub async fn get_backup_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_backup::Request<'_>>,
|
||||
) -> ConduitResult<delete_backup::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -129,7 +129,7 @@ pub async fn delete_backup_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<add_backup_keys::Request<'_>>,
|
||||
) -> ConduitResult<add_backup_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -163,7 +163,7 @@ pub async fn add_backup_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_key_sessions_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<add_backup_key_sessions::Request<'_>>,
|
||||
) -> ConduitResult<add_backup_key_sessions::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -195,7 +195,7 @@ pub async fn add_backup_key_sessions_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_key_session_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<add_backup_key_session::Request<'_>>,
|
||||
) -> ConduitResult<add_backup_key_session::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -224,7 +224,7 @@ pub async fn add_backup_key_session_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_backup_keys::Request<'_>>,
|
||||
) -> ConduitResult<get_backup_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -240,7 +240,7 @@ pub async fn get_backup_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_key_sessions_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_backup_key_sessions::Request<'_>>,
|
||||
) -> ConduitResult<get_backup_key_sessions::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -258,7 +258,7 @@ pub async fn get_backup_key_sessions_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_key_session_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_backup_key_session::Request<'_>>,
|
||||
) -> ConduitResult<get_backup_key_session::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -280,7 +280,7 @@ pub async fn get_backup_key_session_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_backup_keys::Request<'_>>,
|
||||
) -> ConduitResult<delete_backup_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -303,7 +303,7 @@ pub async fn delete_backup_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_key_sessions_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_backup_key_sessions::Request<'_>>,
|
||||
) -> ConduitResult<delete_backup_key_sessions::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -326,7 +326,7 @@ pub async fn delete_backup_key_sessions_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_key_session_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_backup_key_session::Request<'_>>,
|
||||
) -> ConduitResult<delete_backup_key_session::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -22,7 +22,7 @@ use rocket::{get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_global_account_data_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_global_account_data::Request<'_>>,
|
||||
) -> ConduitResult<set_global_account_data::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -57,7 +57,7 @@ pub async fn set_global_account_data_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_room_account_data_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_room_account_data::Request<'_>>,
|
||||
) -> ConduitResult<set_room_account_data::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -89,7 +89,7 @@ pub async fn set_room_account_data_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_global_account_data_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_global_account_data::Request<'_>>,
|
||||
) -> ConduitResult<get_global_account_data::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -116,7 +116,7 @@ pub async fn get_global_account_data_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_room_account_data_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_room_account_data::Request<'_>>,
|
||||
) -> ConduitResult<get_room_account_data::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::api::client::{error::ErrorKind, r0::context::get_context};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rocket::get;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_context_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_context::Request<'_>>,
|
||||
) -> ConduitResult<get_context::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, ConduitResult, Error, Ruma};
|
||||
use ruma::api::client::{
|
||||
error::ErrorKind,
|
||||
r0::{
|
||||
|
@ -17,7 +17,7 @@ use rocket::{delete, get, post, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_devices_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_devices::Request>,
|
||||
) -> ConduitResult<get_devices::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -37,7 +37,7 @@ pub async fn get_devices_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_device_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_device::Request<'_>>,
|
||||
) -> ConduitResult<get_device::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -56,7 +56,7 @@ pub async fn get_device_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_device_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<update_device::Request<'_>>,
|
||||
) -> ConduitResult<update_device::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -82,7 +82,7 @@ pub async fn update_device_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_device_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_device::Request<'_>>,
|
||||
) -> ConduitResult<delete_device::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -136,7 +136,7 @@ pub async fn delete_device_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_devices_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_devices::Request<'_>>,
|
||||
) -> ConduitResult<delete_devices::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Result, Ruma};
|
||||
use log::info;
|
||||
use ruma::{
|
||||
api::{
|
||||
|
@ -32,7 +32,7 @@ use rocket::{get, post, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_public_rooms_filtered_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_public_rooms_filtered::Request<'_>>,
|
||||
) -> ConduitResult<get_public_rooms_filtered::Response> {
|
||||
get_public_rooms_filtered_helper(
|
||||
|
@ -52,7 +52,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::Request<'_>>,
|
||||
) -> ConduitResult<get_public_rooms::Response> {
|
||||
let response = get_public_rooms_filtered_helper(
|
||||
|
@ -81,7 +81,7 @@ pub async fn get_public_rooms_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_room_visibility_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_room_visibility::Request<'_>>,
|
||||
) -> ConduitResult<set_room_visibility::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -111,7 +111,7 @@ pub async fn set_room_visibility_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_room_visibility_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_room_visibility::Request<'_>>,
|
||||
) -> ConduitResult<get_room_visibility::Response> {
|
||||
Ok(get_room_visibility::Response {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::SESSION_ID_LENGTH;
|
||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Error, Result, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, ConduitResult, Database, Error, Result, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -25,7 +25,7 @@ use rocket::{get, post};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<upload_keys::Request>,
|
||||
) -> ConduitResult<upload_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -74,7 +74,7 @@ pub async fn upload_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_keys::Request<'_>>,
|
||||
) -> ConduitResult<get_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -95,7 +95,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::Request>,
|
||||
) -> ConduitResult<claim_keys::Response> {
|
||||
let response = claim_keys_helper(&body.one_time_keys, &db)?;
|
||||
|
@ -111,7 +111,7 @@ pub async fn claim_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_signing_keys_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<upload_signing_keys::Request<'_>>,
|
||||
) -> ConduitResult<upload_signing_keys::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -174,7 +174,7 @@ pub async fn upload_signing_keys_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_signatures_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<upload_signatures::Request>,
|
||||
) -> ConduitResult<upload_signatures::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -235,7 +235,7 @@ pub async fn upload_signatures_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_key_changes_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_key_changes::Request<'_>>,
|
||||
) -> ConduitResult<get_key_changes::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::{database::media::FileMeta, database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{
|
||||
database::media::FileMeta, database::DatabaseGuard, utils, ConduitResult, Error, Ruma,
|
||||
};
|
||||
use ruma::api::client::{
|
||||
error::ErrorKind,
|
||||
r0::media::{create_content, get_content, get_content_thumbnail, get_media_config},
|
||||
|
@ -12,7 +14,9 @@ const MXC_LENGTH: usize = 32;
|
|||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub async fn get_media_config_route(db: ReadGuard) -> ConduitResult<get_media_config::Response> {
|
||||
pub async fn get_media_config_route(
|
||||
db: DatabaseGuard,
|
||||
) -> ConduitResult<get_media_config::Response> {
|
||||
Ok(get_media_config::Response {
|
||||
upload_size: db.globals.max_request_size().into(),
|
||||
}
|
||||
|
@ -25,7 +29,7 @@ pub async fn get_media_config_route(db: ReadGuard) -> ConduitResult<get_media_co
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_content_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_content::Request<'_>>,
|
||||
) -> ConduitResult<create_content::Response> {
|
||||
let mxc = format!(
|
||||
|
@ -63,7 +67,7 @@ pub async fn create_content_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_content_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_content::Request<'_>>,
|
||||
) -> ConduitResult<get_content::Response> {
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
@ -116,7 +120,7 @@ pub async fn get_content_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_content_thumbnail_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_content_thumbnail::Request<'_>>,
|
||||
) -> ConduitResult<get_content_thumbnail::Response> {
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
client_server,
|
||||
database::ReadGuard,
|
||||
database::DatabaseGuard,
|
||||
pdu::{PduBuilder, PduEvent},
|
||||
server_server, utils, ConduitResult, Database, Error, Result, Ruma,
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ use rocket::{get, post};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn join_room_by_id_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<join_room_by_id::Request<'_>>,
|
||||
) -> ConduitResult<join_room_by_id::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -85,7 +85,7 @@ pub async fn join_room_by_id_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn join_room_by_id_or_alias_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<join_room_by_id_or_alias::Request<'_>>,
|
||||
) -> ConduitResult<join_room_by_id_or_alias::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -139,7 +139,7 @@ pub async fn join_room_by_id_or_alias_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn leave_room_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<leave_room::Request<'_>>,
|
||||
) -> ConduitResult<leave_room::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -157,7 +157,7 @@ pub async fn leave_room_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn invite_user_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<invite_user::Request<'_>>,
|
||||
) -> ConduitResult<invite_user::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -177,7 +177,7 @@ pub async fn invite_user_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn kick_user_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<kick_user::Request<'_>>,
|
||||
) -> ConduitResult<kick_user::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -227,7 +227,7 @@ pub async fn kick_user_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn ban_user_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<ban_user::Request<'_>>,
|
||||
) -> ConduitResult<ban_user::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -285,7 +285,7 @@ pub async fn ban_user_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn unban_user_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<unban_user::Request<'_>>,
|
||||
) -> ConduitResult<unban_user::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -334,7 +334,7 @@ pub async fn unban_user_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn forget_room_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<forget_room::Request<'_>>,
|
||||
) -> ConduitResult<forget_room::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -352,7 +352,7 @@ pub async fn forget_room_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn joined_rooms_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<joined_rooms::Request>,
|
||||
) -> ConduitResult<joined_rooms::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -373,7 +373,7 @@ pub async fn joined_rooms_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_member_events_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_member_events::Request<'_>>,
|
||||
) -> ConduitResult<get_member_events::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -403,7 +403,7 @@ pub async fn get_member_events_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn joined_members_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<joined_members::Request<'_>>,
|
||||
) -> ConduitResult<joined_members::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -21,7 +21,7 @@ use rocket::{get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_message_event_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<send_message_event::Request<'_>>,
|
||||
) -> ConduitResult<send_message_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -84,7 +84,7 @@ pub async fn send_message_event_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_message_events_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_message_events::Request<'_>>,
|
||||
) -> ConduitResult<get_message_events::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, utils, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, ConduitResult, Ruma};
|
||||
use ruma::api::client::r0::presence::{get_presence, set_presence};
|
||||
use std::{convert::TryInto, time::Duration};
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rocket::{get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_presence_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_presence::Request<'_>>,
|
||||
) -> ConduitResult<set_presence::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -52,7 +52,7 @@ pub async fn set_presence_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_presence_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_presence::Request<'_>>,
|
||||
) -> ConduitResult<get_presence::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -20,7 +20,7 @@ use rocket::{get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_displayname_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_display_name::Request<'_>>,
|
||||
) -> ConduitResult<set_display_name::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -107,7 +107,7 @@ pub async fn set_displayname_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_displayname_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_display_name::Request<'_>>,
|
||||
) -> ConduitResult<get_display_name::Response> {
|
||||
Ok(get_display_name::Response {
|
||||
|
@ -122,7 +122,7 @@ pub async fn get_displayname_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_avatar_url_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_avatar_url::Request<'_>>,
|
||||
) -> ConduitResult<set_avatar_url::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -209,7 +209,7 @@ pub async fn set_avatar_url_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_avatar_url_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_avatar_url::Request<'_>>,
|
||||
) -> ConduitResult<get_avatar_url::Response> {
|
||||
Ok(get_avatar_url::Response {
|
||||
|
@ -224,7 +224,7 @@ pub async fn get_avatar_url_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_profile_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_profile::Request<'_>>,
|
||||
) -> ConduitResult<get_profile::Response> {
|
||||
if !db.users.exists(&body.user_id)? {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -21,7 +21,7 @@ use rocket::{delete, get, post, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrules_all_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_pushrules_all::Request>,
|
||||
) -> ConduitResult<get_pushrules_all::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -46,7 +46,7 @@ pub async fn get_pushrules_all_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_pushrule::Request<'_>>,
|
||||
) -> ConduitResult<get_pushrule::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -100,7 +100,7 @@ pub async fn get_pushrule_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, req))]
|
||||
pub async fn set_pushrule_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
req: Ruma<set_pushrule::Request<'_>>,
|
||||
) -> ConduitResult<set_pushrule::Response> {
|
||||
let sender_user = req.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -203,7 +203,7 @@ pub async fn set_pushrule_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_actions_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_pushrule_actions::Request<'_>>,
|
||||
) -> ConduitResult<get_pushrule_actions::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -262,7 +262,7 @@ pub async fn get_pushrule_actions_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushrule_actions_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_pushrule_actions::Request<'_>>,
|
||||
) -> ConduitResult<set_pushrule_actions::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -336,7 +336,7 @@ pub async fn set_pushrule_actions_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_enabled_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_pushrule_enabled::Request<'_>>,
|
||||
) -> ConduitResult<get_pushrule_enabled::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -397,7 +397,7 @@ pub async fn get_pushrule_enabled_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushrule_enabled_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_pushrule_enabled::Request<'_>>,
|
||||
) -> ConduitResult<set_pushrule_enabled::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -476,7 +476,7 @@ pub async fn set_pushrule_enabled_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_pushrule_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_pushrule::Request<'_>>,
|
||||
) -> ConduitResult<delete_pushrule::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -545,7 +545,7 @@ pub async fn delete_pushrule_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushers_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_pushers::Request>,
|
||||
) -> ConduitResult<get_pushers::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -562,7 +562,7 @@ pub async fn get_pushers_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushers_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_pusher::Request>,
|
||||
) -> ConduitResult<set_pusher::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -19,7 +19,7 @@ use rocket::post;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_read_marker_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_read_marker::Request<'_>>,
|
||||
) -> ConduitResult<set_read_marker::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -86,7 +86,7 @@ pub async fn set_read_marker_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_receipt_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_receipt::Request<'_>>,
|
||||
) -> ConduitResult<create_receipt::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, ConduitResult, Ruma};
|
||||
use ruma::{
|
||||
api::client::r0::redact::redact_event,
|
||||
events::{room::redaction, EventType},
|
||||
|
@ -13,7 +13,7 @@ use rocket::put;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn redact_event_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<redact_event::Request<'_>>,
|
||||
) -> ConduitResult<redact_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{
|
||||
client_server::invite_helper, database::ReadGuard, pdu::PduBuilder, ConduitResult, Error, Ruma,
|
||||
client_server::invite_helper, database::DatabaseGuard, pdu::PduBuilder, ConduitResult, Error,
|
||||
Ruma,
|
||||
};
|
||||
use log::info;
|
||||
use ruma::{
|
||||
|
@ -25,7 +26,7 @@ use rocket::{get, post};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_room_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_room::Request<'_>>,
|
||||
) -> ConduitResult<create_room::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -295,7 +296,7 @@ pub async fn create_room_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_room_event_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_room_event::Request<'_>>,
|
||||
) -> ConduitResult<get_room_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -323,7 +324,7 @@ pub async fn get_room_event_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upgrade_room_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<upgrade_room::Request<'_>>,
|
||||
_room_id: String,
|
||||
) -> ConduitResult<upgrade_room::Response> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::api::client::{error::ErrorKind, r0::search::search_events};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
@ -12,7 +12,7 @@ use std::collections::BTreeMap;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn search_events_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<search_events::Request<'_>>,
|
||||
) -> ConduitResult<search_events::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, ConduitResult, Error, Ruma};
|
||||
use log::info;
|
||||
use ruma::{
|
||||
api::client::{
|
||||
|
@ -50,7 +50,7 @@ pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response>
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn login_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<login::Request<'_>>,
|
||||
) -> ConduitResult<login::Response> {
|
||||
// Validate login method
|
||||
|
@ -167,7 +167,7 @@ pub async fn login_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn logout_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<logout::Request>,
|
||||
) -> ConduitResult<logout::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -195,7 +195,7 @@ pub async fn logout_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn logout_all_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<logout_all::Request>,
|
||||
) -> ConduitResult<logout_all::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Database, Error, Result, Ruma};
|
||||
use crate::{
|
||||
database::DatabaseGuard, pdu::PduBuilder, ConduitResult, Database, Error, Result, Ruma,
|
||||
};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -24,7 +26,7 @@ use rocket::{get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_state_event_for_key_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<send_state_event::Request<'_>>,
|
||||
) -> ConduitResult<send_state_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -50,7 +52,7 @@ pub async fn send_state_event_for_key_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_state_event_for_empty_key_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<send_state_event::Request<'_>>,
|
||||
) -> ConduitResult<send_state_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -76,7 +78,7 @@ pub async fn send_state_event_for_empty_key_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_state_events::Request<'_>>,
|
||||
) -> ConduitResult<get_state_events::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -123,7 +125,7 @@ pub async fn get_state_events_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_for_key_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_state_events_for_key::Request<'_>>,
|
||||
) -> ConduitResult<get_state_events_for_key::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -174,7 +176,7 @@ pub async fn get_state_events_for_key_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_for_empty_key_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_state_events_for_key::Request<'_>>,
|
||||
) -> ConduitResult<get_state_events_for_key::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Result, Ruma, RumaResponse};
|
||||
use log::error;
|
||||
use ruma::{
|
||||
api::client::r0::{sync::sync_events, uiaa::UiaaResponse},
|
||||
|
@ -34,7 +34,7 @@ use rocket::{get, tokio};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn sync_events_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<sync_events::Request<'_>>,
|
||||
) -> std::result::Result<RumaResponse<sync_events::Response>, RumaResponse<UiaaResponse>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -105,7 +105,7 @@ pub async fn sync_events_route(
|
|||
}
|
||||
|
||||
pub async fn sync_helper_wrapper(
|
||||
db: Arc<ReadGuard>,
|
||||
db: Arc<DatabaseGuard>,
|
||||
sender_user: UserId,
|
||||
sender_device: Box<DeviceId>,
|
||||
since: Option<String>,
|
||||
|
@ -149,7 +149,7 @@ pub async fn sync_helper_wrapper(
|
|||
}
|
||||
|
||||
async fn sync_helper(
|
||||
db: Arc<ReadGuard>,
|
||||
db: Arc<DatabaseGuard>,
|
||||
sender_user: UserId,
|
||||
sender_device: Box<DeviceId>,
|
||||
since: Option<String>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Ruma};
|
||||
use ruma::{
|
||||
api::client::r0::tag::{create_tag, delete_tag, get_tags},
|
||||
events::EventType,
|
||||
|
@ -14,7 +14,7 @@ use rocket::{delete, get, put};
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_tag_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_tag::Request<'_>>,
|
||||
) -> ConduitResult<create_tag::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -51,7 +51,7 @@ pub async fn update_tag_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_tag_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<delete_tag::Request<'_>>,
|
||||
) -> ConduitResult<delete_tag::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
@ -85,7 +85,7 @@ pub async fn delete_tag_route(
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_tags_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_tags::Request<'_>>,
|
||||
) -> ConduitResult<get_tags::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, r0::to_device::send_event_to_device},
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
|
@ -13,7 +13,7 @@ use rocket::put;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_event_to_device_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<send_event_to_device::Request<'_>>,
|
||||
) -> ConduitResult<send_event_to_device::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, utils, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, ConduitResult, Ruma};
|
||||
use create_typing_event::Typing;
|
||||
use ruma::api::client::r0::typing::create_typing_event;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rocket::put;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub fn create_typing_event_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<create_typing_event::Request<'_>>,
|
||||
) -> ConduitResult<create_typing_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Ruma};
|
||||
use ruma::api::client::r0::user_directory::search_users;
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
@ -10,7 +10,7 @@ use rocket::post;
|
|||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn search_users_route(
|
||||
db: ReadGuard,
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<search_users::Request<'_>>,
|
||||
) -> ConduitResult<search_users::Response> {
|
||||
let limit = u64::from(body.limit) as usize;
|
||||
|
|
|
@ -533,9 +533,9 @@ impl Database {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ReadGuard(OwnedRwLockReadGuard<Database>);
|
||||
pub struct DatabaseGuard(OwnedRwLockReadGuard<Database>);
|
||||
|
||||
impl Deref for ReadGuard {
|
||||
impl Deref for DatabaseGuard {
|
||||
type Target = OwnedRwLockReadGuard<Database>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
@ -544,18 +544,18 @@ impl Deref for ReadGuard {
|
|||
}
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> FromRequest<'r> for ReadGuard {
|
||||
impl<'r> FromRequest<'r> for DatabaseGuard {
|
||||
type Error = ();
|
||||
|
||||
async fn from_request(req: &'r Request<'_>) -> rocket::request::Outcome<Self, ()> {
|
||||
let db = try_outcome!(req.guard::<State<'_, Arc<TokioRwLock<Database>>>>().await);
|
||||
|
||||
Ok(ReadGuard(Arc::clone(&db).read_owned().await)).or_forward(())
|
||||
Ok(DatabaseGuard(Arc::clone(&db).read_owned().await)).or_forward(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<ReadGuard> for OwnedRwLockReadGuard<Database> {
|
||||
fn into(self) -> ReadGuard {
|
||||
ReadGuard(self)
|
||||
impl Into<DatabaseGuard> for OwnedRwLockReadGuard<Database> {
|
||||
fn into(self) -> DatabaseGuard {
|
||||
DatabaseGuard(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::ReadGuard, Error};
|
||||
use crate::{database::DatabaseGuard, Error};
|
||||
use ruma::{
|
||||
api::{client::r0::uiaa::UiaaResponse, OutgoingResponse},
|
||||
identifiers::{DeviceId, UserId},
|
||||
|
@ -48,7 +48,7 @@ where
|
|||
async fn from_data(request: &'a Request<'_>, data: Data) -> data::Outcome<Self, Self::Error> {
|
||||
let metadata = T::Incoming::METADATA;
|
||||
let db = request
|
||||
.guard::<ReadGuard>()
|
||||
.guard::<DatabaseGuard>()
|
||||
.await
|
||||
.expect("database was loaded");
|
||||
|
||||
|
|
|
@ -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(
|
|||
|
||||
#[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
|
|||
// 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> {
|
|||
|
||||
#[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> {
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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(
|
|||
)]
|
||||
#[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() {
|
||||
|
|
Loading…
Reference in a new issue