0 errors left!

This commit is contained in:
Timo Kösters 2022-10-08 13:02:52 +02:00 committed by Nyaaori
parent f47a5cd5d5
commit d5b4754cf4
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
59 changed files with 656 additions and 563 deletions

View file

@ -22,19 +22,13 @@ pub trait Data: Send + Sync {
fn find_from_token(&self, token: &str) -> Result<Option<(Box<UserId>, String)>>;
/// Returns an iterator over all users on this homeserver.
fn iter(&self) -> Box<dyn Iterator<Item = Result<Box<UserId>>>>;
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<UserId>>> + 'a>;
/// Returns a list of local users as list of usernames.
///
/// A user account is considered `local` if the length of it's password is greater then zero.
fn list_local_users(&self) -> Result<Vec<String>>;
/// Will only return with Some(username) if the password was not empty and the
/// username could be successfully parsed.
/// If utils::string_from_bytes(...) returns an error that username will be skipped
/// and the error will be logged.
fn get_username_with_valid_password(&self, username: &[u8], password: &[u8]) -> Option<String>;
/// Returns the password hash for the given user.
fn password_hash(&self, user_id: &UserId) -> Result<Option<String>>;
@ -75,7 +69,7 @@ pub trait Data: Send + Sync {
fn all_device_ids<'a>(
&'a self,
user_id: &UserId,
) -> Box<dyn Iterator<Item = Result<Box<DeviceId>>>>;
) -> Box<dyn Iterator<Item = Result<Box<DeviceId>>> + 'a>;
/// Replaces the access token of one device.
fn set_token(&self, user_id: &UserId, device_id: &DeviceId, token: &str) -> Result<()>;
@ -131,7 +125,7 @@ pub trait Data: Send + Sync {
user_or_room_id: &str,
from: u64,
to: Option<u64>,
) -> Box<dyn Iterator<Item = Result<Box<UserId>>>>;
) -> Box<dyn Iterator<Item = Result<Box<UserId>>> + 'a>;
fn mark_device_key_update(&self, user_id: &UserId) -> Result<()>;
@ -193,7 +187,7 @@ pub trait Data: Send + Sync {
fn all_devices_metadata<'a>(
&'a self,
user_id: &UserId,
) -> Box<dyn Iterator<Item = Result<Device>>>;
) -> Box<dyn Iterator<Item = Result<Device>> + 'a>;
/// Creates a new sync filter. Returns the filter id.
fn create_filter(&self, user_id: &UserId, filter: &IncomingFilterDefinition) -> Result<String>;

View file

@ -13,7 +13,7 @@ use ruma::{
use crate::{services, Error, Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -72,14 +72,6 @@ impl Service {
self.db.list_local_users()
}
/// Will only return with Some(username) if the password was not empty and the
/// username could be successfully parsed.
/// If utils::string_from_bytes(...) returns an error that username will be skipped
/// and the error will be logged.
fn get_username_with_valid_password(&self, username: &[u8], password: &[u8]) -> Option<String> {
self.db.get_username_with_valid_password(username, password)
}
/// Returns the password hash for the given user.
pub fn password_hash(&self, user_id: &UserId) -> Result<Option<String>> {
self.db.password_hash(user_id)
@ -275,7 +267,7 @@ impl Service {
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Vec<Raw<AnyToDeviceEvent>>> {
self.get_to_device_events(user_id, device_id)
self.db.get_to_device_events(user_id, device_id)
}
pub fn remove_to_device_events(
@ -302,7 +294,7 @@ impl Service {
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Option<Device>> {
self.get_device_metadata(user_id, device_id)
self.db.get_device_metadata(user_id, device_id)
}
pub fn get_devicelist_version(&self, user_id: &UserId) -> Result<Option<u64>> {