|
|
|
@ -75,23 +75,23 @@ impl StateStore for Rooms { |
|
|
|
.map_err(|e| e.to_string())? |
|
|
|
.map_err(|e| e.to_string())? |
|
|
|
.ok_or_else(|| "PDU via room_id and event_id not found in the db.".to_owned())?; |
|
|
|
.ok_or_else(|| "PDU via room_id and event_id not found in the db.".to_owned())?; |
|
|
|
|
|
|
|
|
|
|
|
utils::deserialize( |
|
|
|
serde_json::from_slice( |
|
|
|
&self |
|
|
|
&self |
|
|
|
.pduid_pdu |
|
|
|
.pduid_pdu |
|
|
|
.get(pid) |
|
|
|
.get(pid) |
|
|
|
.map_err(|e| e.to_string())? |
|
|
|
.map_err(|e| e.to_string())? |
|
|
|
.ok_or_else(|| "PDU via pduid not found in db.".to_owned())?, |
|
|
|
.ok_or_else(|| "PDU via pduid not found in db.".to_owned())?, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
.map_err(|e| e.to_string()) |
|
|
|
.and_then(|pdu: StateEvent| { |
|
|
|
.and_then(|pdu: StateEvent| { |
|
|
|
// conduit's PDU's always contain a room_id but some
|
|
|
|
// conduit's PDU's always contain a room_id but some
|
|
|
|
// of ruma's do not so this must be an Option
|
|
|
|
// of ruma's do not so this must be an Option
|
|
|
|
if pdu.room_id() == Some(room_id) { |
|
|
|
if pdu.room_id() == Some(room_id) { |
|
|
|
Ok(pdu) |
|
|
|
Ok(pdu) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Err(Error::bad_database("Found PDU for incorrect room in db.")) |
|
|
|
Err("Found PDU for incorrect room in db.".into()) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.map_err(|e| e.to_string()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1207,8 +1207,7 @@ impl Rooms { |
|
|
|
let roomid_index = key |
|
|
|
let roomid_index = key |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.enumerate() |
|
|
|
.enumerate() |
|
|
|
.filter(|(_, &b)| b == 0xff) |
|
|
|
.find(|(_, &b)| b == 0xff) |
|
|
|
.nth(0) |
|
|
|
|
|
|
|
.ok_or_else(|| Error::bad_database("Invalid userroomid_joined in db."))? |
|
|
|
.ok_or_else(|| Error::bad_database("Invalid userroomid_joined in db."))? |
|
|
|
.0 |
|
|
|
.0 |
|
|
|
+ 1; // +1 because the room id starts AFTER the separator
|
|
|
|
+ 1; // +1 because the room id starts AFTER the separator
|
|
|
|
|