Fixed more compile time errors
This commit is contained in:
parent
785ddfc4aa
commit
bd8b616ca0
103 changed files with 1617 additions and 2749 deletions
|
@ -1,12 +1,12 @@
|
|||
use ruma::{RoomId, RoomAliasId, api::client::error::ErrorKind};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, services};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, services, Result};
|
||||
|
||||
impl service::rooms::alias::Data for KeyValueDatabase {
|
||||
fn set_alias(
|
||||
&self,
|
||||
alias: &RoomAliasId,
|
||||
room_id: Option<&RoomId>
|
||||
room_id: &RoomId
|
||||
) -> Result<()> {
|
||||
self.alias_roomid
|
||||
.insert(alias.alias().as_bytes(), room_id.as_bytes())?;
|
||||
|
@ -41,7 +41,7 @@ impl service::rooms::alias::Data for KeyValueDatabase {
|
|||
fn resolve_local_alias(
|
||||
&self,
|
||||
alias: &RoomAliasId
|
||||
) -> Result<()> {
|
||||
) -> Result<Option<Box<RoomId>>> {
|
||||
self.alias_roomid
|
||||
.get(alias.alias().as_bytes())?
|
||||
.map(|bytes| {
|
||||
|
@ -56,7 +56,7 @@ impl service::rooms::alias::Data for KeyValueDatabase {
|
|||
fn local_aliases_for_room(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<()> {
|
||||
) -> Result<Box<dyn Iterator<Item=String>>> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
impl service::room::auth_chain::Data for KeyValueDatabase {
|
||||
fn get_cached_eventid_authchain<'a>() -> Result<HashSet<u64>> {
|
||||
use std::{collections::HashSet, mem::size_of};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, Result, utils};
|
||||
|
||||
impl service::rooms::auth_chain::Data for KeyValueDatabase {
|
||||
fn get_cached_eventid_authchain(&self, shorteventid: u64) -> Result<HashSet<u64>> {
|
||||
self.shorteventid_authchain
|
||||
.get(&shorteventid.to_be_bytes())?
|
||||
.map(|chain| {
|
||||
|
@ -12,8 +16,8 @@ impl service::room::auth_chain::Data for KeyValueDatabase {
|
|||
})
|
||||
}
|
||||
|
||||
fn cache_eventid_authchain<'a>(shorteventid: u64, auth_chain: &HashSet<u64>) -> Result<()> {
|
||||
shorteventid_authchain.insert(
|
||||
fn cache_eventid_authchain(&self, shorteventid: u64, auth_chain: &HashSet<u64>) -> Result<()> {
|
||||
self.shorteventid_authchain.insert(
|
||||
&shorteventid.to_be_bytes(),
|
||||
&auth_chain
|
||||
.iter()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::RoomId;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, Result};
|
||||
|
||||
impl service::rooms::directory::Data for KeyValueDatabase {
|
||||
fn set_public(&self, room_id: &RoomId) -> Result<()> {
|
||||
|
@ -15,7 +15,7 @@ impl service::rooms::directory::Data for KeyValueDatabase {
|
|||
Ok(self.publicroomids.get(room_id.as_bytes())?.is_some())
|
||||
}
|
||||
|
||||
fn public_rooms(&self) -> impl Iterator<Item = Result<Box<RoomId>>> + '_ {
|
||||
fn public_rooms(&self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>>> {
|
||||
self.publicroomids.iter().map(|(bytes, _)| {
|
||||
RoomId::parse(
|
||||
utils::string_from_bytes(&bytes).map_err(|_| {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
mod presence;
|
||||
mod typing;
|
||||
mod read_receipt;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase};
|
||||
|
||||
impl service::rooms::edus::Data for KeyValueDatabase {}
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||
|
||||
use ruma::{UserId, RoomId, events::presence::PresenceEvent, presence::PresenceState, UInt};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, services};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, services, Result};
|
||||
|
||||
impl service::rooms::edus::presence::Data for KeyValueDatabase {
|
||||
fn update_presence(
|
||||
|
@ -56,8 +56,8 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase {
|
|||
|
||||
fn get_presence_event(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
user_id: &UserId,
|
||||
count: u64,
|
||||
) -> Result<Option<PresenceEvent>> {
|
||||
let mut presence_id = room_id.as_bytes().to_vec();
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::mem;
|
|||
|
||||
use ruma::{UserId, RoomId, events::receipt::ReceiptEvent, serde::Raw, signatures::CanonicalJsonObject};
|
||||
|
||||
use crate::{database::KeyValueDatabase, service, utils, Error, services};
|
||||
use crate::{database::KeyValueDatabase, service, utils, Error, services, Result};
|
||||
|
||||
impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
||||
fn readreceipt_update(
|
||||
|
@ -50,13 +50,13 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
|
|||
&'a self,
|
||||
room_id: &RoomId,
|
||||
since: u64,
|
||||
) -> impl Iterator<
|
||||
) -> Box<dyn Iterator<
|
||||
Item=Result<(
|
||||
Box<UserId>,
|
||||
u64,
|
||||
Raw<ruma::events::AnySyncEphemeralRoomEvent>,
|
||||
)>,
|
||||
> + 'a {
|
||||
>> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
let prefix2 = prefix.clone();
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashSet;
|
|||
|
||||
use ruma::{UserId, RoomId};
|
||||
|
||||
use crate::{database::KeyValueDatabase, service, utils, Error, services};
|
||||
use crate::{database::KeyValueDatabase, service, utils, Error, services, Result};
|
||||
|
||||
impl service::rooms::edus::typing::Data for KeyValueDatabase {
|
||||
fn typing_add(
|
||||
|
@ -79,7 +79,7 @@ impl service::rooms::edus::typing::Data for KeyValueDatabase {
|
|||
fn typings_all(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<HashSet<UserId>> {
|
||||
) -> Result<HashSet<Box<UserId>>> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::{UserId, DeviceId, RoomId};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase};
|
||||
use crate::{service, database::KeyValueDatabase, Result};
|
||||
|
||||
impl service::rooms::lazy_loading::Data for KeyValueDatabase {
|
||||
fn lazy_load_was_sent_before(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::RoomId;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase};
|
||||
use crate::{service, database::KeyValueDatabase, Result};
|
||||
|
||||
impl service::rooms::metadata::Data for KeyValueDatabase {
|
||||
fn exists(&self, room_id: &RoomId) -> Result<bool> {
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
mod alias;
|
||||
mod auth_chain;
|
||||
mod directory;
|
||||
mod edus;
|
||||
//mod event_handler;
|
||||
mod lazy_load;
|
||||
mod metadata;
|
||||
mod outlier;
|
||||
mod pdu_metadata;
|
||||
mod search;
|
||||
//mod short;
|
||||
mod short;
|
||||
mod state;
|
||||
mod state_accessor;
|
||||
mod state_cache;
|
||||
mod state_compressor;
|
||||
mod timeline;
|
||||
mod user;
|
||||
|
||||
use crate::{database::KeyValueDatabase, service};
|
||||
|
||||
impl service::rooms::Data for KeyValueDatabase {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::{EventId, signatures::CanonicalJsonObject};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, PduEvent, Error};
|
||||
use crate::{service, database::KeyValueDatabase, PduEvent, Error, Result};
|
||||
|
||||
impl service::rooms::outlier::Data for KeyValueDatabase {
|
||||
fn get_outlier_pdu_json(&self, event_id: &EventId) -> Result<Option<CanonicalJsonObject>> {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||
|
||||
use ruma::{RoomId, EventId};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase};
|
||||
use crate::{service, database::KeyValueDatabase, Result};
|
||||
|
||||
impl service::rooms::pdu_metadata::Data for KeyValueDatabase {
|
||||
fn mark_as_referenced(&self, room_id: &RoomId, event_ids: &[Arc<EventId>]) -> Result<()> {
|
||||
|
|
|
@ -2,10 +2,10 @@ use std::mem::size_of;
|
|||
|
||||
use ruma::RoomId;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Result};
|
||||
|
||||
impl service::rooms::search::Data for KeyValueDatabase {
|
||||
fn index_pdu<'a>(&self, room_id: &RoomId, pdu_id: u64, message_body: String) -> Result<()> {
|
||||
fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: u64, message_body: String) -> Result<()> {
|
||||
let mut batch = message_body
|
||||
.split_terminator(|c: char| !c.is_alphanumeric())
|
||||
.filter(|s| !s.is_empty())
|
||||
|
@ -26,7 +26,7 @@ impl service::rooms::search::Data for KeyValueDatabase {
|
|||
&'a self,
|
||||
room_id: &RoomId,
|
||||
search_string: &str,
|
||||
) -> Result<Option<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)>> {
|
||||
) -> Result<Option<(Box<dyn Iterator<Item = Vec<u8>>>, Vec<String>)>> {
|
||||
let prefix = self
|
||||
.get_shortroomid(room_id)?
|
||||
.expect("room exists")
|
||||
|
|
4
src/database/key_value/rooms/short.rs
Normal file
4
src/database/key_value/rooms/short.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
use crate::{database::KeyValueDatabase, service};
|
||||
|
||||
impl service::rooms::short::Data for KeyValueDatabase {
|
||||
}
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use std::{sync::MutexGuard, collections::HashSet};
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, Result};
|
||||
|
||||
impl service::rooms::state::Data for KeyValueDatabase {
|
||||
fn get_room_shortstatehash(&self, room_id: &RoomId) -> Result<Option<u64>> {
|
||||
|
@ -24,7 +24,7 @@ impl service::rooms::state::Data for KeyValueDatabase {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_event_state(&self, shorteventid: Vec<u8>, shortstatehash: Vec<u8>) -> Result<()> {
|
||||
fn set_event_state(&self, shorteventid: u64, shortstatehash: u64) -> Result<()> {
|
||||
self.shorteventid_shortstatehash
|
||||
.insert(&shorteventid.to_be_bytes(), &shortstatehash.to_be_bytes())?;
|
||||
Ok(())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{collections::{BTreeMap, HashMap}, sync::Arc};
|
||||
|
||||
use crate::{database::KeyValueDatabase, service, PduEvent, Error, utils};
|
||||
use crate::{database::KeyValueDatabase, service, PduEvent, Error, utils, Result};
|
||||
use async_trait::async_trait;
|
||||
use ruma::{EventId, events::StateEventType, RoomId};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::{UserId, RoomId};
|
||||
use ruma::{UserId, RoomId, events::{AnyStrippedStateEvent, AnySyncStateEvent}, serde::Raw};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase};
|
||||
use crate::{service, database::KeyValueDatabase, services, Result};
|
||||
|
||||
impl service::rooms::state_cache::Data for KeyValueDatabase {
|
||||
fn mark_as_once_joined(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
|
@ -9,4 +9,70 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
self.roomuseroncejoinedids.insert(&userroom_id, &[])
|
||||
}
|
||||
|
||||
fn mark_as_joined(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
let mut roomuser_id = room_id.as_bytes().to_vec();
|
||||
roomuser_id.push(0xff);
|
||||
roomuser_id.extend_from_slice(user_id.as_bytes());
|
||||
|
||||
let mut userroom_id = user_id.as_bytes().to_vec();
|
||||
userroom_id.push(0xff);
|
||||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
|
||||
self.userroomid_joined.insert(&userroom_id, &[])?;
|
||||
self.roomuserid_joined.insert(&roomuser_id, &[])?;
|
||||
self.userroomid_invitestate.remove(&userroom_id)?;
|
||||
self.roomuserid_invitecount.remove(&roomuser_id)?;
|
||||
self.userroomid_leftstate.remove(&userroom_id)?;
|
||||
self.roomuserid_leftcount.remove(&roomuser_id)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mark_as_invited(&self, user_id: &UserId, room_id: &RoomId, last_state: Option<Vec<Raw<AnyStrippedStateEvent>>>) -> Result<()> {
|
||||
let mut roomuser_id = room_id.as_bytes().to_vec();
|
||||
roomuser_id.push(0xff);
|
||||
roomuser_id.extend_from_slice(user_id.as_bytes());
|
||||
|
||||
let mut userroom_id = user_id.as_bytes().to_vec();
|
||||
userroom_id.push(0xff);
|
||||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
|
||||
self.userroomid_invitestate.insert(
|
||||
&userroom_id,
|
||||
&serde_json::to_vec(&last_state.unwrap_or_default())
|
||||
.expect("state to bytes always works"),
|
||||
)?;
|
||||
self.roomuserid_invitecount
|
||||
.insert(&roomuser_id, &services().globals.next_count()?.to_be_bytes())?;
|
||||
self.userroomid_joined.remove(&userroom_id)?;
|
||||
self.roomuserid_joined.remove(&roomuser_id)?;
|
||||
self.userroomid_leftstate.remove(&userroom_id)?;
|
||||
self.roomuserid_leftcount.remove(&roomuser_id)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mark_as_left(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
let mut roomuser_id = room_id.as_bytes().to_vec();
|
||||
roomuser_id.push(0xff);
|
||||
roomuser_id.extend_from_slice(user_id.as_bytes());
|
||||
|
||||
let mut userroom_id = user_id.as_bytes().to_vec();
|
||||
userroom_id.push(0xff);
|
||||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
|
||||
self.userroomid_leftstate.insert(
|
||||
&userroom_id,
|
||||
&serde_json::to_vec(&Vec::<Raw<AnySyncStateEvent>>::new()).unwrap(),
|
||||
)?; // TODO
|
||||
self.roomuserid_leftcount
|
||||
.insert(&roomuser_id, &services().globals.next_count()?.to_be_bytes())?;
|
||||
self.userroomid_joined.remove(&userroom_id)?;
|
||||
self.roomuserid_joined.remove(&roomuser_id)?;
|
||||
self.userroomid_invitestate.remove(&userroom_id)?;
|
||||
self.roomuserid_invitecount.remove(&roomuser_id)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{collections::HashSet, mem::size_of};
|
||||
|
||||
use crate::{service::{self, rooms::state_compressor::data::StateDiff}, database::KeyValueDatabase, Error, utils};
|
||||
use crate::{service::{self, rooms::state_compressor::data::StateDiff}, database::KeyValueDatabase, Error, utils, Result};
|
||||
|
||||
impl service::rooms::state_compressor::Data for KeyValueDatabase {
|
||||
fn get_statediff(&self, shortstatehash: u64) -> Result<StateDiff> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{collections::hash_map, mem::size_of, sync::Arc};
|
|||
use ruma::{UserId, RoomId, api::client::error::ErrorKind, EventId, signatures::CanonicalJsonObject};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, PduEvent};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, PduEvent, Result};
|
||||
|
||||
impl service::rooms::timeline::Data for KeyValueDatabase {
|
||||
fn last_timeline_count(&self, sender_user: &UserId, room_id: &RoomId) -> Result<u64> {
|
||||
|
@ -190,7 +190,7 @@ impl service::rooms::timeline::Data for KeyValueDatabase {
|
|||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
since: u64,
|
||||
) -> Result<impl Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a> {
|
||||
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>> {
|
||||
let prefix = self
|
||||
.get_shortroomid(room_id)?
|
||||
.expect("room exists")
|
||||
|
@ -224,7 +224,7 @@ impl service::rooms::timeline::Data for KeyValueDatabase {
|
|||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
until: u64,
|
||||
) -> Result<impl Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a> {
|
||||
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>> {
|
||||
// Create the first part of the full pdu id
|
||||
let prefix = self
|
||||
.get_shortroomid(room_id)?
|
||||
|
@ -258,7 +258,7 @@ impl service::rooms::timeline::Data for KeyValueDatabase {
|
|||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
from: u64,
|
||||
) -> Result<impl Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a> {
|
||||
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>> {
|
||||
// Create the first part of the full pdu id
|
||||
let prefix = self
|
||||
.get_shortroomid(room_id)?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::{UserId, RoomId};
|
||||
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error};
|
||||
use crate::{service, database::KeyValueDatabase, utils, Error, Result};
|
||||
|
||||
impl service::rooms::user::Data for KeyValueDatabase {
|
||||
fn reset_notification_counts(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
|
@ -78,7 +78,7 @@ impl service::rooms::user::Data for KeyValueDatabase {
|
|||
fn get_shared_rooms<'a>(
|
||||
&'a self,
|
||||
users: Vec<Box<UserId>>,
|
||||
) -> Result<impl Iterator<Item = Result<Box<RoomId>>> + 'a> {
|
||||
) -> Result<Box<dyn Iterator<Item = Result<Box<RoomId>>>>> {
|
||||
let iterators = users.into_iter().map(move |user_id| {
|
||||
let mut prefix = user_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue