mirror of https://gitlab.com/famedly/conduit.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.9 KiB
87 lines
2.9 KiB
use std::sync::Arc; |
|
|
|
use ruma::{CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId}; |
|
|
|
use crate::{PduEvent, Result}; |
|
|
|
pub trait Data: Send + Sync { |
|
fn first_pdu_in_room(&self, room_id: &RoomId) -> Result<Option<Arc<PduEvent>>>; |
|
fn last_timeline_count(&self, sender_user: &UserId, room_id: &RoomId) -> Result<u64>; |
|
|
|
/// Returns the `count` of this pdu's id. |
|
fn get_pdu_count(&self, event_id: &EventId) -> Result<Option<u64>>; |
|
|
|
/// Returns the json of a pdu. |
|
fn get_pdu_json(&self, event_id: &EventId) -> Result<Option<CanonicalJsonObject>>; |
|
|
|
/// Returns the json of a pdu. |
|
fn get_non_outlier_pdu_json(&self, event_id: &EventId) -> Result<Option<CanonicalJsonObject>>; |
|
|
|
/// Returns the pdu's id. |
|
fn get_pdu_id(&self, event_id: &EventId) -> Result<Option<Vec<u8>>>; |
|
|
|
/// Returns the pdu. |
|
/// |
|
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline. |
|
fn get_non_outlier_pdu(&self, event_id: &EventId) -> Result<Option<PduEvent>>; |
|
|
|
/// Returns the pdu. |
|
/// |
|
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline. |
|
fn get_pdu(&self, event_id: &EventId) -> Result<Option<Arc<PduEvent>>>; |
|
|
|
/// Returns the pdu. |
|
/// |
|
/// This does __NOT__ check the outliers `Tree`. |
|
fn get_pdu_from_id(&self, pdu_id: &[u8]) -> Result<Option<PduEvent>>; |
|
|
|
/// Returns the pdu as a `BTreeMap<String, CanonicalJsonValue>`. |
|
fn get_pdu_json_from_id(&self, pdu_id: &[u8]) -> Result<Option<CanonicalJsonObject>>; |
|
|
|
/// Returns the `count` of this pdu's id. |
|
fn pdu_count(&self, pdu_id: &[u8]) -> Result<u64>; |
|
|
|
/// Adds a new pdu to the timeline |
|
fn append_pdu( |
|
&self, |
|
pdu_id: &[u8], |
|
pdu: &PduEvent, |
|
json: &CanonicalJsonObject, |
|
count: u64, |
|
) -> Result<()>; |
|
|
|
/// Removes a pdu and creates a new one with the same id. |
|
fn replace_pdu(&self, pdu_id: &[u8], pdu: &PduEvent) -> Result<()>; |
|
|
|
/// Returns an iterator over all events in a room that happened after the event with id `since` |
|
/// in chronological order. |
|
fn pdus_since<'a>( |
|
&'a self, |
|
user_id: &UserId, |
|
room_id: &RoomId, |
|
since: u64, |
|
) -> 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. |
|
fn pdus_until<'a>( |
|
&'a self, |
|
user_id: &UserId, |
|
room_id: &RoomId, |
|
until: u64, |
|
) -> 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)>> + 'a>>; |
|
|
|
fn increment_notification_counts( |
|
&self, |
|
room_id: &RoomId, |
|
notifies: Vec<OwnedUserId>, |
|
highlights: Vec<OwnedUserId>, |
|
) -> Result<()>; |
|
}
|
|
|