fix invalid database code for servers_invite_via

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-14 15:21:03 -04:00 committed by June
parent 59ba3e3190
commit 878dcd71bb
2 changed files with 10 additions and 4 deletions

View File

@ -1597,6 +1597,8 @@ async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
HashSet::from_iter,
);
debug!("servers in remote_leave_room: {servers:?}");
for remote_server in servers {
let make_leave_response = services()
.sending

View File

@ -6,6 +6,7 @@ use ruma::{
serde::Raw,
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
};
use tracing::error;
use crate::{
database::KeyValueDatabase,
@ -589,13 +590,16 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
#[tracing::instrument(skip(self))]
fn servers_invite_via(&self, room_id: &RoomId) -> Result<Option<Vec<OwnedServerName>>> {
let room_id = room_id.as_bytes().to_vec();
let mut key = room_id.as_bytes().to_vec();
key.push(0xFF);
self.roomid_inviteviaservers
.get(&room_id)?
.get(&key)?
.map(|servers| {
let state = serde_json::from_slice(&servers)
.map_err(|_| Error::bad_database("Invalid state in userroomid_leftstate."))?;
let state = serde_json::from_slice(&servers).map_err(|e| {
error!("Invalid state in userroomid_leftstate: {e}");
Error::bad_database("Invalid state in userroomid_leftstate.")
})?;
Ok(state)
})