conduwuit/src/service/rooms/outlier/mod.rs

30 lines
815 B
Rust
Raw Normal View History

mod data;
2022-10-05 18:36:12 +02:00
use std::sync::Arc;
pub use data::Data;
2022-10-05 20:34:31 +02:00
use ruma::{signatures::CanonicalJsonObject, EventId};
2022-10-05 20:34:31 +02:00
use crate::{PduEvent, Result};
2022-10-05 12:45:54 +02:00
pub struct Service {
2022-10-05 18:36:12 +02:00
db: Arc<dyn Data>,
}
2022-10-05 12:45:54 +02:00
impl Service {
2022-06-20 11:31:27 +02:00
/// Returns the pdu from the outlier tree.
pub fn get_outlier_pdu_json(&self, event_id: &EventId) -> Result<Option<CanonicalJsonObject>> {
self.db.get_outlier_pdu_json(event_id)
2022-06-20 11:31:27 +02:00
}
/// Returns the pdu from the outlier tree.
pub fn get_pdu_outlier(&self, event_id: &EventId) -> Result<Option<PduEvent>> {
self.db.get_outlier_pdu(event_id)
}
/// Append the PDU as an outlier.
#[tracing::instrument(skip(self, pdu))]
pub fn add_pdu_outlier(&self, event_id: &EventId, pdu: &CanonicalJsonObject) -> Result<()> {
self.db.add_pdu_outlier(event_id, pdu)
2021-08-28 11:39:33 +02:00
}
}