|
|
|
@ -93,14 +93,10 @@ impl Rooms { |
|
|
|
.map(|(_, bytes)| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.map(|(_, bytes)| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.flatten() |
|
|
|
.flatten() |
|
|
|
.map(|bytes| { |
|
|
|
.map(|bytes| { |
|
|
|
Ok::<_, Error>( |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database("EventID in stateid_shorteventid is invalid unicode.") |
|
|
|
Error::bad_database("EventID in stateid_shorteventid is invalid unicode.") |
|
|
|
})?) |
|
|
|
})?) |
|
|
|
.map_err(|_| Error::bad_database("EventId in stateid_shorteventid is invalid.")) |
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
Error::bad_database("EventId in stateid_shorteventid is invalid.") |
|
|
|
|
|
|
|
})?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
.collect()) |
|
|
|
.collect()) |
|
|
|
@ -116,14 +112,10 @@ impl Rooms { |
|
|
|
.map(|(_, bytes)| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.map(|(_, bytes)| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.flatten() |
|
|
|
.flatten() |
|
|
|
.map(|bytes| { |
|
|
|
.map(|bytes| { |
|
|
|
Ok::<_, Error>( |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database("EventID in stateid_shorteventid is invalid unicode.") |
|
|
|
Error::bad_database("EventID in stateid_shorteventid is invalid unicode.") |
|
|
|
})?) |
|
|
|
})?) |
|
|
|
.map_err(|_| Error::bad_database("EventId in stateid_shorteventid is invalid.")) |
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
Error::bad_database("EventId in stateid_shorteventid is invalid.") |
|
|
|
|
|
|
|
})?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
.map(|eventid| self.get_pdu(&eventid)) |
|
|
|
.map(|eventid| self.get_pdu(&eventid)) |
|
|
|
@ -168,16 +160,10 @@ impl Rooms { |
|
|
|
.map(|bytes| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.map(|bytes| self.shorteventid_eventid.get(&bytes).ok().flatten()) |
|
|
|
.flatten() |
|
|
|
.flatten() |
|
|
|
.map(|bytes| { |
|
|
|
.map(|bytes| { |
|
|
|
Ok::<_, Error>( |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database("EventID in stateid_shorteventid is invalid unicode.") |
|
|
|
Error::bad_database( |
|
|
|
})?) |
|
|
|
"EventID in stateid_shorteventid is invalid unicode.", |
|
|
|
.map_err(|_| Error::bad_database("EventId in stateid_shorteventid is invalid.")) |
|
|
|
) |
|
|
|
|
|
|
|
})?) |
|
|
|
|
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
Error::bad_database("EventId in stateid_shorteventid is invalid.") |
|
|
|
|
|
|
|
})?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.map(|r| r.ok()) |
|
|
|
.map(|r| r.ok()) |
|
|
|
.flatten()) |
|
|
|
.flatten()) |
|
|
|
@ -204,16 +190,16 @@ impl Rooms { |
|
|
|
self.eventid_shorteventid |
|
|
|
self.eventid_shorteventid |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.map_or(Ok(None), |shorteventid| { |
|
|
|
.map_or(Ok(None), |shorteventid| { |
|
|
|
Ok(self |
|
|
|
self.shorteventid_shortstatehash.get(&shorteventid)?.map_or( |
|
|
|
.shorteventid_shortstatehash |
|
|
|
Ok::<_, Error>(None), |
|
|
|
.get(&shorteventid)? |
|
|
|
|bytes| { |
|
|
|
.map_or(Ok::<_, Error>(None), |bytes| { |
|
|
|
|
|
|
|
Ok(Some(utils::u64_from_bytes(&bytes).map_err(|_| { |
|
|
|
Ok(Some(utils::u64_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database( |
|
|
|
Error::bad_database( |
|
|
|
"Invalid shortstatehash bytes in shorteventid_shortstatehash", |
|
|
|
"Invalid shortstatehash bytes in shorteventid_shortstatehash", |
|
|
|
) |
|
|
|
) |
|
|
|
})?)) |
|
|
|
})?)) |
|
|
|
})?) |
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -485,7 +471,7 @@ impl Rooms { |
|
|
|
self.eventid_pduid |
|
|
|
self.eventid_pduid |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.map_or_else::<Result<_>, _, _>( |
|
|
|
.map_or_else::<Result<_>, _, _>( |
|
|
|
|| Ok(self.eventid_outlierpdu.get(event_id.as_bytes())?), |
|
|
|
|| self.eventid_outlierpdu.get(event_id.as_bytes()), |
|
|
|
|pduid| { |
|
|
|
|pduid| { |
|
|
|
Ok(Some(self.pduid_pdu.get(&pduid)?.ok_or_else(|| { |
|
|
|
Ok(Some(self.pduid_pdu.get(&pduid)?.ok_or_else(|| { |
|
|
|
Error::bad_database("Invalid pduid in eventid_pduid.") |
|
|
|
Error::bad_database("Invalid pduid in eventid_pduid.") |
|
|
|
@ -493,8 +479,7 @@ impl Rooms { |
|
|
|
}, |
|
|
|
}, |
|
|
|
)? |
|
|
|
)? |
|
|
|
.map(|pdu| { |
|
|
|
.map(|pdu| { |
|
|
|
Ok(serde_json::from_slice(&pdu) |
|
|
|
serde_json::from_slice(&pdu).map_err(|_| Error::bad_database("Invalid PDU in db.")) |
|
|
|
.map_err(|_| Error::bad_database("Invalid PDU in db."))?) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.transpose() |
|
|
|
.transpose() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -521,8 +506,7 @@ impl Rooms { |
|
|
|
}, |
|
|
|
}, |
|
|
|
)? |
|
|
|
)? |
|
|
|
.map(|pdu| { |
|
|
|
.map(|pdu| { |
|
|
|
Ok(serde_json::from_slice(&pdu) |
|
|
|
serde_json::from_slice(&pdu).map_err(|_| Error::bad_database("Invalid PDU in db.")) |
|
|
|
.map_err(|_| Error::bad_database("Invalid PDU in db."))?) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.transpose() |
|
|
|
.transpose() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -534,7 +518,7 @@ impl Rooms { |
|
|
|
self.eventid_pduid |
|
|
|
self.eventid_pduid |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.get(event_id.as_bytes())? |
|
|
|
.map_or_else::<Result<_>, _, _>( |
|
|
|
.map_or_else::<Result<_>, _, _>( |
|
|
|
|| Ok(self.eventid_outlierpdu.get(event_id.as_bytes())?), |
|
|
|
|| self.eventid_outlierpdu.get(event_id.as_bytes()), |
|
|
|
|pduid| { |
|
|
|
|pduid| { |
|
|
|
Ok(Some(self.pduid_pdu.get(&pduid)?.ok_or_else(|| { |
|
|
|
Ok(Some(self.pduid_pdu.get(&pduid)?.ok_or_else(|| { |
|
|
|
Error::bad_database("Invalid pduid in eventid_pduid.") |
|
|
|
Error::bad_database("Invalid pduid in eventid_pduid.") |
|
|
|
@ -542,8 +526,7 @@ impl Rooms { |
|
|
|
}, |
|
|
|
}, |
|
|
|
)? |
|
|
|
)? |
|
|
|
.map(|pdu| { |
|
|
|
.map(|pdu| { |
|
|
|
Ok(serde_json::from_slice(&pdu) |
|
|
|
serde_json::from_slice(&pdu).map_err(|_| Error::bad_database("Invalid PDU in db.")) |
|
|
|
.map_err(|_| Error::bad_database("Invalid PDU in db."))?) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.transpose() |
|
|
|
.transpose() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -594,12 +577,10 @@ impl Rooms { |
|
|
|
self.roomid_pduleaves |
|
|
|
self.roomid_pduleaves |
|
|
|
.scan_prefix(prefix) |
|
|
|
.scan_prefix(prefix) |
|
|
|
.map(|(_, bytes)| { |
|
|
|
.map(|(_, bytes)| { |
|
|
|
Ok::<_, Error>( |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database("EventID in roomid_pduleaves is invalid unicode.") |
|
|
|
Error::bad_database("EventID in roomid_pduleaves is invalid unicode.") |
|
|
|
})?) |
|
|
|
})?) |
|
|
|
.map_err(|_| Error::bad_database("EventId in roomid_pduleaves is invalid.")) |
|
|
|
.map_err(|_| Error::bad_database("EventId in roomid_pduleaves is invalid."))?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect() |
|
|
|
.collect() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1213,12 +1194,10 @@ impl Rooms { |
|
|
|
let create_event_content = create_event |
|
|
|
let create_event_content = create_event |
|
|
|
.as_ref() |
|
|
|
.as_ref() |
|
|
|
.map(|create_event| { |
|
|
|
.map(|create_event| { |
|
|
|
Ok::<_, Error>( |
|
|
|
serde_json::from_value::<Raw<CreateEventContent>>(create_event.content.clone()) |
|
|
|
serde_json::from_value::<Raw<CreateEventContent>>(create_event.content.clone()) |
|
|
|
.expect("Raw::from_value always works.") |
|
|
|
.expect("Raw::from_value always works.") |
|
|
|
.deserialize() |
|
|
|
.deserialize() |
|
|
|
.map_err(|_| Error::bad_database("Invalid PowerLevels event in db.")) |
|
|
|
.map_err(|_| Error::bad_database("Invalid PowerLevels event in db."))?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.transpose()?; |
|
|
|
.transpose()?; |
|
|
|
|
|
|
|
|
|
|
|
@ -1382,13 +1361,12 @@ impl Rooms { |
|
|
|
.map_or_else(Vec::new, |users| { |
|
|
|
.map_or_else(Vec::new, |users| { |
|
|
|
users |
|
|
|
users |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.map(|users| { |
|
|
|
.filter_map(|users| { |
|
|
|
users |
|
|
|
users |
|
|
|
.get("regex") |
|
|
|
.get("regex") |
|
|
|
.and_then(|regex| regex.as_str()) |
|
|
|
.and_then(|regex| regex.as_str()) |
|
|
|
.and_then(|regex| Regex::new(regex).ok()) |
|
|
|
.and_then(|regex| Regex::new(regex).ok()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.filter_map(|o| o) |
|
|
|
|
|
|
|
.collect::<Vec<_>>() |
|
|
|
.collect::<Vec<_>>() |
|
|
|
}); |
|
|
|
}); |
|
|
|
let aliases = namespaces |
|
|
|
let aliases = namespaces |
|
|
|
@ -1397,13 +1375,12 @@ impl Rooms { |
|
|
|
.map_or_else(Vec::new, |aliases| { |
|
|
|
.map_or_else(Vec::new, |aliases| { |
|
|
|
aliases |
|
|
|
aliases |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.map(|aliases| { |
|
|
|
.filter_map(|aliases| { |
|
|
|
aliases |
|
|
|
aliases |
|
|
|
.get("regex") |
|
|
|
.get("regex") |
|
|
|
.and_then(|regex| regex.as_str()) |
|
|
|
.and_then(|regex| regex.as_str()) |
|
|
|
.and_then(|regex| Regex::new(regex).ok()) |
|
|
|
.and_then(|regex| Regex::new(regex).ok()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.filter_map(|o| o) |
|
|
|
|
|
|
|
.collect::<Vec<_>>() |
|
|
|
.collect::<Vec<_>>() |
|
|
|
}); |
|
|
|
}); |
|
|
|
let rooms = namespaces |
|
|
|
let rooms = namespaces |
|
|
|
@ -2011,10 +1988,10 @@ impl Rooms { |
|
|
|
prefix.push(0xff); |
|
|
|
prefix.push(0xff); |
|
|
|
|
|
|
|
|
|
|
|
self.aliasid_alias.scan_prefix(prefix).map(|(_, bytes)| { |
|
|
|
self.aliasid_alias.scan_prefix(prefix).map(|(_, bytes)| { |
|
|
|
Ok(utils::string_from_bytes(&bytes) |
|
|
|
utils::string_from_bytes(&bytes) |
|
|
|
.map_err(|_| Error::bad_database("Invalid alias bytes in aliasid_alias."))? |
|
|
|
.map_err(|_| Error::bad_database("Invalid alias bytes in aliasid_alias."))? |
|
|
|
.try_into() |
|
|
|
.try_into() |
|
|
|
.map_err(|_| Error::bad_database("Invalid alias in aliasid_alias."))?) |
|
|
|
.map_err(|_| Error::bad_database("Invalid alias in aliasid_alias.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2032,14 +2009,14 @@ impl Rooms { |
|
|
|
Ok(self.publicroomids.get(room_id.as_bytes())?.is_some()) |
|
|
|
Ok(self.publicroomids.get(room_id.as_bytes())?.is_some()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn public_rooms<'a>(&'a self) -> impl Iterator<Item = Result<RoomId>> + 'a { |
|
|
|
pub fn public_rooms(&self) -> impl Iterator<Item = Result<RoomId>> + '_ { |
|
|
|
self.publicroomids.iter().map(|(bytes, _)| { |
|
|
|
self.publicroomids.iter().map(|(bytes, _)| { |
|
|
|
Ok( |
|
|
|
RoomId::try_from( |
|
|
|
RoomId::try_from(utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
utils::string_from_bytes(&bytes).map_err(|_| { |
|
|
|
Error::bad_database("Room ID in publicroomids is invalid unicode.") |
|
|
|
Error::bad_database("Room ID in publicroomids is invalid unicode.") |
|
|
|
})?) |
|
|
|
})?, |
|
|
|
.map_err(|_| Error::bad_database("Room ID in publicroomids is invalid."))?, |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
.map_err(|_| Error::bad_database("Room ID in publicroomids is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2105,34 +2082,27 @@ impl Rooms { |
|
|
|
&'a self, |
|
|
|
&'a self, |
|
|
|
users: Vec<UserId>, |
|
|
|
users: Vec<UserId>, |
|
|
|
) -> Result<impl Iterator<Item = Result<RoomId>> + 'a> { |
|
|
|
) -> Result<impl Iterator<Item = Result<RoomId>> + 'a> { |
|
|
|
let iterators = users |
|
|
|
let iterators = users.into_iter().map(move |user_id| { |
|
|
|
.into_iter() |
|
|
|
let mut prefix = user_id.as_bytes().to_vec(); |
|
|
|
.map(move |user_id| { |
|
|
|
prefix.push(0xff); |
|
|
|
let mut prefix = user_id.as_bytes().to_vec(); |
|
|
|
|
|
|
|
prefix.push(0xff); |
|
|
|
self.userroomid_joined |
|
|
|
|
|
|
|
.scan_prefix(prefix) |
|
|
|
Ok::<_, Error>( |
|
|
|
.map(|(key, _)| { |
|
|
|
self.userroomid_joined |
|
|
|
let roomid_index = key |
|
|
|
.scan_prefix(prefix) |
|
|
|
.iter() |
|
|
|
.map(|(key, _)| { |
|
|
|
.enumerate() |
|
|
|
let roomid_index = key |
|
|
|
.find(|(_, &b)| b == 0xff) |
|
|
|
.iter() |
|
|
|
.ok_or_else(|| Error::bad_database("Invalid userroomid_joined in db."))? |
|
|
|
.enumerate() |
|
|
|
.0 |
|
|
|
.find(|(_, &b)| b == 0xff) |
|
|
|
+ 1; // +1 because the room id starts AFTER the separator
|
|
|
|
.ok_or_else(|| { |
|
|
|
|
|
|
|
Error::bad_database("Invalid userroomid_joined in db.") |
|
|
|
let room_id = key[roomid_index..].to_vec(); |
|
|
|
})? |
|
|
|
|
|
|
|
.0 |
|
|
|
Ok::<_, Error>(room_id) |
|
|
|
+ 1; // +1 because the room id starts AFTER the separator
|
|
|
|
}) |
|
|
|
|
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
let room_id = key[roomid_index..].to_vec(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Ok::<_, Error>(room_id) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.filter_map(|r| r.ok()), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.filter_map(|r| r.ok()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We use the default compare function because keys are sorted correctly (not reversed)
|
|
|
|
// We use the default compare function because keys are sorted correctly (not reversed)
|
|
|
|
Ok(utils::common_elements(iterators, Ord::cmp) |
|
|
|
Ok(utils::common_elements(iterators, Ord::cmp) |
|
|
|
@ -2154,7 +2124,7 @@ impl Rooms { |
|
|
|
prefix.push(0xff); |
|
|
|
prefix.push(0xff); |
|
|
|
|
|
|
|
|
|
|
|
self.roomserverids.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
self.roomserverids.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
Ok(Box::<ServerName>::try_from( |
|
|
|
Box::<ServerName>::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2164,7 +2134,7 @@ impl Rooms { |
|
|
|
Error::bad_database("Server name in roomserverids is invalid unicode.") |
|
|
|
Error::bad_database("Server name in roomserverids is invalid unicode.") |
|
|
|
})?, |
|
|
|
})?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("Server name in roomserverids is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("Server name in roomserverids is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2177,7 +2147,7 @@ impl Rooms { |
|
|
|
prefix.push(0xff); |
|
|
|
prefix.push(0xff); |
|
|
|
|
|
|
|
|
|
|
|
self.serverroomids.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
self.serverroomids.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
Ok(RoomId::try_from( |
|
|
|
RoomId::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2185,7 +2155,7 @@ impl Rooms { |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("RoomId in serverroomids is invalid unicode."))?, |
|
|
|
.map_err(|_| Error::bad_database("RoomId in serverroomids is invalid unicode."))?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("RoomId in serverroomids is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("RoomId in serverroomids is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2199,7 +2169,7 @@ impl Rooms { |
|
|
|
prefix.push(0xff); |
|
|
|
prefix.push(0xff); |
|
|
|
|
|
|
|
|
|
|
|
self.roomuserid_joined.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
self.roomuserid_joined.scan_prefix(prefix).map(|(key, _)| { |
|
|
|
Ok(UserId::try_from( |
|
|
|
UserId::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2209,7 +2179,7 @@ impl Rooms { |
|
|
|
Error::bad_database("User ID in roomuserid_joined is invalid unicode.") |
|
|
|
Error::bad_database("User ID in roomuserid_joined is invalid unicode.") |
|
|
|
})?, |
|
|
|
})?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("User ID in roomuserid_joined is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("User ID in roomuserid_joined is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2224,7 +2194,7 @@ impl Rooms { |
|
|
|
self.roomuseroncejoinedids |
|
|
|
self.roomuseroncejoinedids |
|
|
|
.scan_prefix(prefix) |
|
|
|
.scan_prefix(prefix) |
|
|
|
.map(|(key, _)| { |
|
|
|
.map(|(key, _)| { |
|
|
|
Ok(UserId::try_from( |
|
|
|
UserId::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2234,7 +2204,7 @@ impl Rooms { |
|
|
|
Error::bad_database("User ID in room_useroncejoined is invalid unicode.") |
|
|
|
Error::bad_database("User ID in room_useroncejoined is invalid unicode.") |
|
|
|
})?, |
|
|
|
})?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("User ID in room_useroncejoined is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("User ID in room_useroncejoined is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2250,7 +2220,7 @@ impl Rooms { |
|
|
|
self.roomuserid_invitecount |
|
|
|
self.roomuserid_invitecount |
|
|
|
.scan_prefix(prefix) |
|
|
|
.scan_prefix(prefix) |
|
|
|
.map(|(key, _)| { |
|
|
|
.map(|(key, _)| { |
|
|
|
Ok(UserId::try_from( |
|
|
|
UserId::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2260,7 +2230,7 @@ impl Rooms { |
|
|
|
Error::bad_database("User ID in roomuserid_invited is invalid unicode.") |
|
|
|
Error::bad_database("User ID in roomuserid_invited is invalid unicode.") |
|
|
|
})?, |
|
|
|
})?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("User ID in roomuserid_invited is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("User ID in roomuserid_invited is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2303,7 +2273,7 @@ impl Rooms { |
|
|
|
self.userroomid_joined |
|
|
|
self.userroomid_joined |
|
|
|
.scan_prefix(user_id.as_bytes().to_vec()) |
|
|
|
.scan_prefix(user_id.as_bytes().to_vec()) |
|
|
|
.map(|(key, _)| { |
|
|
|
.map(|(key, _)| { |
|
|
|
Ok(RoomId::try_from( |
|
|
|
RoomId::try_from( |
|
|
|
utils::string_from_bytes( |
|
|
|
utils::string_from_bytes( |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
&key.rsplit(|&b| b == 0xff) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
@ -2313,7 +2283,7 @@ impl Rooms { |
|
|
|
Error::bad_database("Room ID in userroomid_joined is invalid unicode.") |
|
|
|
Error::bad_database("Room ID in userroomid_joined is invalid unicode.") |
|
|
|
})?, |
|
|
|
})?, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| Error::bad_database("Room ID in userroomid_joined is invalid."))?) |
|
|
|
.map_err(|_| Error::bad_database("Room ID in userroomid_joined is invalid.")) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|