Eliminate rooms outlier service, duplicate subset of timeline service.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -638,7 +638,7 @@ pub(super) async fn force_set_room_state_from_server(
|
||||
|
||||
self.services
|
||||
.rooms
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
|
||||
if let Some(state_key) = &pdu.state_key {
|
||||
@@ -668,7 +668,7 @@ pub(super) async fn force_set_room_state_from_server(
|
||||
|
||||
self.services
|
||||
.rooms
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
}
|
||||
|
||||
|
||||
@@ -561,8 +561,9 @@ async fn join_room_by_id_helper_remote(
|
||||
|
||||
services
|
||||
.rooms
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
|
||||
if let Some(state_key) = &pdu.state_key {
|
||||
let shortstatekey = services
|
||||
.rooms
|
||||
@@ -595,7 +596,7 @@ async fn join_room_by_id_helper_remote(
|
||||
.ready_for_each(|(event_id, value)| {
|
||||
services
|
||||
.rooms
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -541,8 +541,9 @@ async fn knock_room_helper_remote(
|
||||
|
||||
services
|
||||
.rooms
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(&event_id, &event);
|
||||
|
||||
state_map.insert(shortstatekey, event_id.clone());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ where
|
||||
if json_opt.is_none() {
|
||||
json_opt = self
|
||||
.services
|
||||
.outlier
|
||||
.timeline
|
||||
.get_outlier_pdu_json(&prev_event_id)
|
||||
.await
|
||||
.ok();
|
||||
|
||||
@@ -151,7 +151,7 @@ where
|
||||
|
||||
// 7. Persist the event as an outlier.
|
||||
self.services
|
||||
.outlier
|
||||
.timeline
|
||||
.add_pdu_outlier(pdu_event.event_id(), &incoming_pdu);
|
||||
|
||||
trace!("Added pdu as outlier.");
|
||||
|
||||
@@ -41,7 +41,6 @@ struct Services {
|
||||
sending: Dep<sending::Service>,
|
||||
auth_chain: Dep<rooms::auth_chain::Service>,
|
||||
metadata: Dep<rooms::metadata::Service>,
|
||||
outlier: Dep<rooms::outlier::Service>,
|
||||
pdu_metadata: Dep<rooms::pdu_metadata::Service>,
|
||||
server_keys: Dep<server_keys::Service>,
|
||||
short: Dep<rooms::short::Service>,
|
||||
@@ -66,7 +65,6 @@ impl crate::Service for Service {
|
||||
sending: args.depend::<sending::Service>("sending"),
|
||||
auth_chain: args.depend::<rooms::auth_chain::Service>("rooms::auth_chain"),
|
||||
metadata: args.depend::<rooms::metadata::Service>("rooms::metadata"),
|
||||
outlier: args.depend::<rooms::outlier::Service>("rooms::outlier"),
|
||||
server_keys: args.depend::<server_keys::Service>("server_keys"),
|
||||
pdu_metadata: args.depend::<rooms::pdu_metadata::Service>("rooms::pdu_metadata"),
|
||||
short: args.depend::<rooms::short::Service>("rooms::short"),
|
||||
|
||||
@@ -4,7 +4,6 @@ pub mod directory;
|
||||
pub mod event_handler;
|
||||
pub mod lazy_loading;
|
||||
pub mod metadata;
|
||||
pub mod outlier;
|
||||
pub mod pdu_metadata;
|
||||
pub mod read_receipt;
|
||||
pub mod search;
|
||||
@@ -28,7 +27,6 @@ pub struct Service {
|
||||
pub event_handler: Arc<event_handler::Service>,
|
||||
pub lazy_loading: Arc<lazy_loading::Service>,
|
||||
pub metadata: Arc<metadata::Service>,
|
||||
pub outlier: Arc<outlier::Service>,
|
||||
pub pdu_metadata: Arc<pdu_metadata::Service>,
|
||||
pub read_receipt: Arc<read_receipt::Service>,
|
||||
pub search: Arc<search::Service>,
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use ruma::{CanonicalJsonObject, EventId};
|
||||
use tuwunel_core::{Result, implement, matrix::PduEvent};
|
||||
use tuwunel_database::{Deserialized, Json, Map};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
}
|
||||
|
||||
struct Data {
|
||||
eventid_outlierpdu: Arc<Map>,
|
||||
}
|
||||
|
||||
impl crate::Service for Service {
|
||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
db: Data {
|
||||
eventid_outlierpdu: args.db["eventid_outlierpdu"].clone(),
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||
}
|
||||
|
||||
/// Returns the pdu from the outlier tree.
|
||||
#[implement(Service)]
|
||||
pub async fn get_outlier_pdu_json(&self, event_id: &EventId) -> Result<CanonicalJsonObject> {
|
||||
self.db
|
||||
.eventid_outlierpdu
|
||||
.get(event_id)
|
||||
.await
|
||||
.deserialized()
|
||||
}
|
||||
|
||||
/// Returns the pdu from the outlier tree.
|
||||
#[implement(Service)]
|
||||
pub async fn get_pdu_outlier(&self, event_id: &EventId) -> Result<PduEvent> {
|
||||
self.db
|
||||
.eventid_outlierpdu
|
||||
.get(event_id)
|
||||
.await
|
||||
.deserialized()
|
||||
}
|
||||
|
||||
/// Append the PDU as an outlier.
|
||||
#[implement(Service)]
|
||||
#[tracing::instrument(skip(self, pdu), level = "debug")]
|
||||
pub fn add_pdu_outlier(&self, event_id: &EventId, pdu: &CanonicalJsonObject) {
|
||||
self.db
|
||||
.eventid_outlierpdu
|
||||
.raw_put(event_id, Json(pdu));
|
||||
}
|
||||
@@ -167,6 +167,14 @@ pub async fn replace_pdu(&self, pdu_id: &RawPduId, pdu_json: &CanonicalJsonObjec
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
#[tracing::instrument(skip(self, pdu), level = "debug")]
|
||||
pub fn add_pdu_outlier(&self, event_id: &EventId, pdu: &CanonicalJsonObject) {
|
||||
self.db
|
||||
.eventid_outlierpdu
|
||||
.raw_put(event_id, Json(pdu));
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
#[tracing::instrument(skip(self), level = "debug")]
|
||||
pub async fn first_pdu_in_room(&self, room_id: &RoomId) -> Result<PduEvent> {
|
||||
|
||||
@@ -82,7 +82,6 @@ impl Services {
|
||||
event_handler: build!(rooms::event_handler::Service),
|
||||
lazy_loading: build!(rooms::lazy_loading::Service),
|
||||
metadata: build!(rooms::metadata::Service),
|
||||
outlier: build!(rooms::outlier::Service),
|
||||
pdu_metadata: build!(rooms::pdu_metadata::Service),
|
||||
read_receipt: build!(rooms::read_receipt::Service),
|
||||
search: build!(rooms::search::Service),
|
||||
|
||||
Reference in New Issue
Block a user