From cc0bde5b4dde1c1d17d09793f61a1991e3bea02e Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Sun, 6 Apr 2025 20:03:09 -0700 Subject: [PATCH] set default database backend in nixos module to rocksdb The media backend already has a default value. --- nix/modules/default/default.nix | 31 ++++++++++++++++++++----------- src/api/server_server.rs | 31 +++++-------------------------- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/nix/modules/default/default.nix b/nix/modules/default/default.nix index 1bd8f8d6..38468e44 100644 --- a/nix/modules/default/default.nix +++ b/nix/modules/default/default.nix @@ -40,18 +40,27 @@ in ''; default = false; }; - database.path = lib.mkOption { - type = types.nonEmptyStr; - readOnly = true; - description = '' - The path to store database files in. + database = { + backend = lib.mkOption { + type = types.nonEmptyStr; + description = '' + The database backend to use. + ''; + default = "rocksdb"; + }; + path = lib.mkOption { + type = types.nonEmptyStr; + readOnly = true; + description = '' + The path to store database files in. - Note that this is read-only because this module makes use of - systemd's `StateDirectory` option. - ''; - default = if cfg.settings.conduit_compat - then "/var/lib/matrix-conduit/database" - else "/var/lib/grapevine/database"; + Note that this is read-only because this module makes use of + systemd's `StateDirectory` option. + ''; + default = if cfg.settings.conduit_compat + then "/var/lib/matrix-conduit/database" + else "/var/lib/grapevine/database"; + }; }; media.backend = { type = lib.mkOption { diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 9c29b60b..426a1a89 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -716,7 +716,10 @@ pub(crate) fn parse_incoming_pdu( let room_version_id = services() .rooms .state - .get_create_content::(&room_id)?; + .get_create_content::(&room_id) + .inspect_err(|_| { + debug!(%room_id, "This server is not in the room"); + })?; let Ok((event_id, value)) = gen_event_id_canonical_json(pdu, &room_version_id) @@ -745,31 +748,7 @@ pub(crate) async fn send_transaction_message_route( let pub_key_map = RwLock::new(BTreeMap::new()); for pdu in &body.pdus { - let value: CanonicalJsonObject = serde_json::from_str(pdu.get()) - .map_err(|error| { - warn!(%error, object = ?pdu, "Error parsing incoming event"); - Error::BadServerResponse("Invalid PDU in server response") - })?; - let room_id: OwnedRoomId = value - .get("room_id") - .and_then(|id| RoomId::parse(id.as_str()?).ok()) - .ok_or(Error::BadRequest( - ErrorKind::InvalidParam, - "Invalid room id in pdu", - ))?; - - if services() - .rooms - .state - .get_create_content::(&room_id) - .is_err() - { - debug!(%room_id, "This server is not in the room"); - continue; - } - - let r = parse_incoming_pdu(pdu); - let (event_id, value, room_id) = match r { + let (event_id, value, room_id) = match parse_incoming_pdu(pdu) { Ok(t) => t, Err(error) => { warn!(%error, object = ?pdu, "Error parsing incoming event");