mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
Add wrapper types for short IDs
This commit is contained in:
parent
f1642c92d1
commit
b0f33207fe
28 changed files with 427 additions and 232 deletions
|
|
@ -2,7 +2,10 @@ use ruma::RoomId;
|
|||
|
||||
use crate::{
|
||||
database::KeyValueDatabase,
|
||||
service::{self, rooms::timeline::PduId},
|
||||
service::{
|
||||
self,
|
||||
rooms::{short::ShortRoomId, timeline::PduId},
|
||||
},
|
||||
services, utils, Result,
|
||||
};
|
||||
|
||||
|
|
@ -21,12 +24,12 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
|||
#[tracing::instrument(skip(self))]
|
||||
fn index_pdu(
|
||||
&self,
|
||||
shortroomid: u64,
|
||||
shortroomid: ShortRoomId,
|
||||
pdu_id: &PduId,
|
||||
message_body: &str,
|
||||
) -> Result<()> {
|
||||
let mut batch = tokenize(message_body).map(|word| {
|
||||
let mut key = shortroomid.to_be_bytes().to_vec();
|
||||
let mut key = shortroomid.get().to_be_bytes().to_vec();
|
||||
key.extend_from_slice(word.as_bytes());
|
||||
key.push(0xFF);
|
||||
// TODO: currently we save the room id a second time here
|
||||
|
|
@ -40,12 +43,12 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
|||
#[tracing::instrument(skip(self))]
|
||||
fn deindex_pdu(
|
||||
&self,
|
||||
shortroomid: u64,
|
||||
shortroomid: ShortRoomId,
|
||||
pdu_id: &PduId,
|
||||
message_body: &str,
|
||||
) -> Result<()> {
|
||||
let batch = tokenize(message_body).map(|word| {
|
||||
let mut key = shortroomid.to_be_bytes().to_vec();
|
||||
let mut key = shortroomid.get().to_be_bytes().to_vec();
|
||||
key.extend_from_slice(word.as_bytes());
|
||||
key.push(0xFF);
|
||||
// TODO: currently we save the room id a second time here
|
||||
|
|
@ -73,6 +76,7 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
|||
.short
|
||||
.get_shortroomid(room_id)?
|
||||
.expect("room exists")
|
||||
.get()
|
||||
.to_be_bytes()
|
||||
.to_vec();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue