feat: swappable database backend

This commit is contained in:
Timo Kösters 2021-06-08 18:10:00 +02:00
parent 81715bd84d
commit d0ee823254
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
47 changed files with 1434 additions and 981 deletions

View file

@ -7,14 +7,14 @@ use ruma::api::client::{
#[cfg(feature = "conduit_bin")]
use rocket::{get, post};
use std::convert::TryInto;
use std::{convert::TryInto, sync::Arc};
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: State<'_, Database>,
db: State<'_, Arc<Database>>,
) -> ConduitResult<get_media_config::Response> {
Ok(get_media_config::Response {
upload_size: db.globals.max_request_size().into(),
@ -28,7 +28,7 @@ pub async fn get_media_config_route(
)]
#[tracing::instrument(skip(db, body))]
pub async fn create_content_route(
db: State<'_, Database>,
db: State<'_, Arc<Database>>,
body: Ruma<create_content::Request<'_>>,
) -> ConduitResult<create_content::Response> {
let mxc = format!(
@ -62,7 +62,7 @@ pub async fn create_content_route(
)]
#[tracing::instrument(skip(db, body))]
pub async fn get_content_route(
db: State<'_, Database>,
db: State<'_, Arc<Database>>,
body: Ruma<get_content::Request<'_>>,
) -> ConduitResult<get_content::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
@ -112,7 +112,7 @@ pub async fn get_content_route(
)]
#[tracing::instrument(skip(db, body))]
pub async fn get_content_thumbnail_route(
db: State<'_, Database>,
db: State<'_, Arc<Database>>,
body: Ruma<get_content_thumbnail::Request<'_>>,
) -> ConduitResult<get_content_thumbnail::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);