mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
Add PduId wrapper struct
Death to Vec<u8>
This commit is contained in:
parent
341f4213d0
commit
26322d5a95
15 changed files with 110 additions and 71 deletions
|
|
@ -6,8 +6,9 @@ use ruma::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
database::KeyValueDatabase, service, services, utils, Error, PduEvent,
|
||||
Result,
|
||||
database::KeyValueDatabase,
|
||||
service::{self, rooms::timeline::PduId},
|
||||
services, utils, Error, PduEvent, Result,
|
||||
};
|
||||
|
||||
impl service::rooms::threads::Data for KeyValueDatabase {
|
||||
|
|
@ -42,6 +43,9 @@ impl service::rooms::threads::Data for KeyValueDatabase {
|
|||
"Invalid pduid in threadid_userids.",
|
||||
)
|
||||
})?;
|
||||
|
||||
let pduid = PduId::new(pduid);
|
||||
|
||||
let mut pdu = services()
|
||||
.rooms
|
||||
.timeline
|
||||
|
|
@ -61,7 +65,7 @@ impl service::rooms::threads::Data for KeyValueDatabase {
|
|||
|
||||
fn update_participants(
|
||||
&self,
|
||||
root_id: &[u8],
|
||||
root_id: &PduId,
|
||||
participants: &[OwnedUserId],
|
||||
) -> Result<()> {
|
||||
let users = participants
|
||||
|
|
@ -70,16 +74,16 @@ impl service::rooms::threads::Data for KeyValueDatabase {
|
|||
.collect::<Vec<_>>()
|
||||
.join(&[0xFF][..]);
|
||||
|
||||
self.threadid_userids.insert(root_id, &users)?;
|
||||
self.threadid_userids.insert(root_id.as_bytes(), &users)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_participants(
|
||||
&self,
|
||||
root_id: &[u8],
|
||||
root_id: &PduId,
|
||||
) -> Result<Option<Vec<OwnedUserId>>> {
|
||||
if let Some(users) = self.threadid_userids.get(root_id)? {
|
||||
if let Some(users) = self.threadid_userids.get(root_id.as_bytes())? {
|
||||
Ok(Some(
|
||||
users
|
||||
.split(|b| *b == 0xFF)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue