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

@ -12,8 +12,8 @@ pub trait Data: Send + Sync {
fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<Box<RoomId>>>;
/// Returns all local aliases that point to the given room
fn local_aliases_for_room(
&self,
fn local_aliases_for_room<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<RoomAliasId>>>>;
) -> Box<dyn Iterator<Item = Result<Box<RoomAliasId>>> + 'a>;
}

View file

@ -7,7 +7,7 @@ use crate::Result;
use ruma::{RoomAliasId, RoomId};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -30,7 +30,7 @@ impl Service {
pub fn local_aliases_for_room<'a>(
&'a self,
room_id: &RoomId,
) -> impl Iterator<Item = Result<Box<RoomAliasId>>> + 'a {
) -> Box<dyn Iterator<Item = Result<Box<RoomAliasId>>> + 'a> {
self.db.local_aliases_for_room(room_id)
}
}

View file

@ -11,7 +11,7 @@ use tracing::log::warn;
use crate::{services, Error, Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -12,5 +12,5 @@ pub trait Data: Send + Sync {
fn is_public_room(&self, room_id: &RoomId) -> Result<bool>;
/// Returns the unsorted public room directory
fn public_rooms(&self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>>>;
fn public_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a>;
}

View file

@ -7,7 +7,7 @@ use ruma::RoomId;
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -2,7 +2,7 @@ pub mod presence;
pub mod read_receipt;
pub mod typing;
pub trait Data: presence::Data + read_receipt::Data + typing::Data {}
pub trait Data: presence::Data + read_receipt::Data + typing::Data + 'static {}
pub struct Service {
pub presence: presence::Service,

View file

@ -7,7 +7,7 @@ use ruma::{events::presence::PresenceEvent, RoomId, UserId};
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -11,8 +11,8 @@ pub trait Data: Send + Sync {
) -> Result<()>;
/// Returns an iterator over the most recent read_receipts in a room that happened after the event with id `since`.
fn readreceipts_since(
&self,
fn readreceipts_since<'a>(
&'a self,
room_id: &RoomId,
since: u64,
) -> Box<
@ -22,7 +22,7 @@ pub trait Data: Send + Sync {
u64,
Raw<ruma::events::AnySyncEphemeralRoomEvent>,
)>,
>,
> + 'a,
>;
/// Sets a private read marker at `count`.

View file

@ -7,7 +7,7 @@ use crate::Result;
use ruma::{events::receipt::ReceiptEvent, serde::Raw, RoomId, UserId};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -7,7 +7,7 @@ use ruma::{events::SyncEphemeralRoomEvent, RoomId, UserId};
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -256,7 +256,7 @@ impl Service {
#[tracing::instrument(skip(self, create_event, value, pub_key_map))]
fn handle_outlier_pdu<'a>(
&self,
&'a self,
origin: &'a ServerName,
create_event: &'a PduEvent,
event_id: &'a EventId,
@ -1015,7 +1015,7 @@ impl Service {
/// d. TODO: Ask other servers over federation?
#[tracing::instrument(skip_all)]
pub(crate) fn fetch_and_handle_outliers<'a>(
&self,
&'a self,
origin: &'a ServerName,
events: &'a [Arc<EventId>],
create_event: &'a PduEvent,

View file

@ -10,9 +10,9 @@ use ruma::{DeviceId, RoomId, UserId};
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
lazy_load_waiting:
pub lazy_load_waiting:
Mutex<HashMap<(Box<UserId>, Box<DeviceId>, Box<RoomId>, u64), HashSet<Box<UserId>>>>,
}
@ -67,7 +67,7 @@ impl Service {
user_id,
device_id,
room_id,
&mut user_ids.iter().map(|&u| &*u),
&mut user_ids.iter().map(|u| &**u),
)?;
} else {
// Ignore

View file

@ -3,6 +3,7 @@ use ruma::RoomId;
pub trait Data: Send + Sync {
fn exists(&self, room_id: &RoomId) -> Result<bool>;
fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a>;
fn is_disabled(&self, room_id: &RoomId) -> Result<bool>;
fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()>;
}

View file

@ -7,7 +7,7 @@ use ruma::RoomId;
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -17,6 +17,10 @@ impl Service {
self.db.exists(room_id)
}
pub fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
self.db.iter_ids()
}
pub fn is_disabled(&self, room_id: &RoomId) -> Result<bool> {
self.db.is_disabled(room_id)
}

View file

@ -7,7 +7,7 @@ use ruma::{signatures::CanonicalJsonObject, EventId};
use crate::{PduEvent, Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -7,7 +7,7 @@ use ruma::{EventId, RoomId};
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -2,11 +2,11 @@ use crate::Result;
use ruma::RoomId;
pub trait Data: Send + Sync {
fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: String) -> Result<()>;
fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>;
fn search_pdus<'a>(
&'a self,
room_id: &RoomId,
search_string: &str,
) -> Result<Option<(Box<dyn Iterator<Item = Vec<u8>>>, Vec<String>)>>;
) -> Result<Option<(Box<dyn Iterator<Item = Vec<u8>>+ 'a>, Vec<String>)>>;
}

View file

@ -7,7 +7,7 @@ use crate::Result;
use ruma::RoomId;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -16,7 +16,7 @@ impl Service {
&self,
shortroomid: u64,
pdu_id: &[u8],
message_body: String,
message_body: &str,
) -> Result<()> {
self.db.index_pdu(shortroomid, pdu_id, message_body)
}

View file

@ -7,7 +7,7 @@ use ruma::{events::StateEventType, EventId, RoomId};
use crate::{Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -23,7 +23,7 @@ use crate::{services, utils::calculate_hash, Error, PduEvent, Result};
use super::state_compressor::CompressedStateEvent;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -33,7 +33,7 @@ impl Service {
room_id: &RoomId,
shortstatehash: u64,
statediffnew: HashSet<CompressedStateEvent>,
statediffremoved: HashSet<CompressedStateEvent>,
_statediffremoved: HashSet<CompressedStateEvent>,
) -> Result<()> {
let mutex_state = Arc::clone(
services()
@ -102,7 +102,7 @@ impl Service {
services().rooms.state_cache.update_joined_count(room_id)?;
self.db.set_room_state(room_id, shortstatehash, &state_lock);
self.db.set_room_state(room_id, shortstatehash, &state_lock)?;
drop(state_lock);

View file

@ -10,7 +10,7 @@ use ruma::{events::StateEventType, EventId, RoomId};
use crate::{PduEvent, Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {

View file

@ -17,7 +17,7 @@ use ruma::{
use crate::{services, Error, Result};
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {
@ -112,7 +112,7 @@ impl Service {
};
// Copy direct chat flag
if let Some(mut direct_event) = services()
if let Some(direct_event) = services()
.account_data
.get(
None,
@ -125,7 +125,7 @@ impl Service {
})
})
{
let direct_event = direct_event?;
let mut direct_event = direct_event?;
let mut room_ids_updated = false;
for room_ids in direct_event.content.0.values_mut() {

View file

@ -14,7 +14,7 @@ use crate::{services, utils, Result};
use self::data::StateDiff;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
pub stateinfo_cache: Mutex<
LruCache<

View file

@ -60,7 +60,7 @@ pub trait Data: Send + Sync {
user_id: &UserId,
room_id: &RoomId,
since: u64,
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>>;
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a>>;
/// Returns an iterator over all events and their tokens in a room that happened before the
/// event with id `until` in reverse-chronological order.
@ -69,14 +69,14 @@ pub trait Data: Send + Sync {
user_id: &UserId,
room_id: &RoomId,
until: u64,
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>>;
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a>>;
fn pdus_after<'a>(
&'a self,
user_id: &UserId,
room_id: &RoomId,
from: u64,
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>>>>;
) -> Result<Box<dyn Iterator<Item = Result<(Vec<u8>, PduEvent)>> + 'a>>;
fn increment_notification_counts(
&self,

View file

@ -36,9 +36,9 @@ use crate::{
use super::state_compressor::CompressedStateEvent;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
pub(super) lasttimelinecount_cache: Mutex<HashMap<Box<RoomId>, u64>>,
pub lasttimelinecount_cache: Mutex<HashMap<Box<RoomId>, u64>>,
}
impl Service {
@ -253,10 +253,10 @@ impl Service {
.rooms
.state_cache
.get_our_real_users(&pdu.room_id)?
.into_iter()
.iter()
{
// Don't notify the user of their own events
if &user == &pdu.sender {
if user == &pdu.sender {
continue;
}
@ -297,20 +297,20 @@ impl Service {
}
if notify {
notifies.push(user);
notifies.push(user.clone());
}
if highlight {
highlights.push(user);
highlights.push(user.clone());
}
for senderkey in services().pusher.get_pusher_senderkeys(&user) {
services().sending.send_push_pdu(&*pdu_id, senderkey)?;
for push_key in services().pusher.get_pushkeys(&user) {
services().sending.send_push_pdu(&*pdu_id, &user, push_key?)?;
}
}
self.db
.increment_notification_counts(&pdu.room_id, notifies, highlights);
.increment_notification_counts(&pdu.room_id, notifies, highlights)?;
match pdu.kind {
RoomEventType::RoomRedaction => {
@ -365,7 +365,7 @@ impl Service {
services()
.rooms
.search
.index_pdu(shortroomid, &pdu_id, body)?;
.index_pdu(shortroomid, &pdu_id, &body)?;
let admin_room = services().rooms.alias.resolve_local_alias(
<&RoomAliasId>::try_from(
@ -398,7 +398,7 @@ impl Service {
{
services()
.sending
.send_pdu_appservice(&appservice.0, &pdu_id)?;
.send_pdu_appservice(appservice.0, pdu_id.clone())?;
continue;
}
@ -422,7 +422,7 @@ impl Service {
if state_key_uid == &appservice_uid {
services()
.sending
.send_pdu_appservice(&appservice.0, &pdu_id)?;
.send_pdu_appservice(appservice.0, pdu_id.clone())?;
continue;
}
}
@ -475,7 +475,7 @@ impl Service {
{
services()
.sending
.send_pdu_appservice(&appservice.0, &pdu_id)?;
.send_pdu_appservice(appservice.0, pdu_id.clone())?;
}
}
}
@ -565,7 +565,7 @@ impl Service {
}
}
let pdu = PduEvent {
let mut pdu = PduEvent {
event_id: ruma::event_id!("$thiswillbefilledinlater").into(),
room_id: room_id.to_owned(),
sender: sender.to_owned(),

View file

@ -20,5 +20,5 @@ pub trait Data: Send + Sync {
fn get_shared_rooms<'a>(
&'a self,
users: Vec<Box<UserId>>,
) -> Result<Box<dyn Iterator<Item = Result<Box<RoomId>>>>>;
) -> Result<Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a>>;
}

View file

@ -7,7 +7,7 @@ use ruma::{RoomId, UserId};
use crate::Result;
pub struct Service {
db: Arc<dyn Data>,
pub db: &'static dyn Data,
}
impl Service {