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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
947 B
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use conduit::{Result, Server};
use data::Data;
use database::Database;
2022-10-09 17:25:06 +02:00
use ruma::{CanonicalJsonObject, EventId};
use crate::PduEvent;
pub struct Service {
db: Data,
}
2022-10-05 12:45:54 +02:00
impl Service {
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
Ok(Self {
db: Data::new(db),
})
}
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.
///
/// TODO: use this?
#[allow(dead_code)]
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
}
}