partially revert e507c31306
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
61174dd0d3
commit
3962333043
8 changed files with 13 additions and 18 deletions
|
@ -57,7 +57,7 @@ impl Data {
|
|||
) -> impl Stream<Item = PdusIterItem> + Send + '_ {
|
||||
let mut current = ArrayVec::<u8, 16>::new();
|
||||
current.extend(target.to_be_bytes());
|
||||
current.extend(from.into_unsigned().to_be_bytes());
|
||||
current.extend(from.saturating_inc(dir).into_unsigned().to_be_bytes());
|
||||
let current = current.as_slice();
|
||||
match dir {
|
||||
Direction::Forward => self.tofrom_relation.raw_keys_from(current).boxed(),
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Service {
|
|||
|
||||
let current: RawPduId = PduId {
|
||||
shortroomid,
|
||||
shorteventid,
|
||||
shorteventid: shorteventid.saturating_sub(1),
|
||||
}
|
||||
.into();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use conduit::{
|
|||
};
|
||||
use database::{Database, Deserialized, Json, KeyVal, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{CanonicalJsonObject, EventId, OwnedRoomId, OwnedUserId, RoomId, UserId};
|
||||
use ruma::{api::Direction, CanonicalJsonObject, EventId, OwnedRoomId, OwnedUserId, RoomId, UserId};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use super::{PduId, RawPduId};
|
||||
|
@ -205,7 +205,9 @@ impl Data {
|
|||
pub(super) async fn pdus_rev<'a>(
|
||||
&'a self, user_id: Option<&'a UserId>, room_id: &'a RoomId, until: PduCount,
|
||||
) -> Result<impl Stream<Item = PdusIterItem> + Send + 'a> {
|
||||
let current = self.count_to_id(room_id, until).await?;
|
||||
let current = self
|
||||
.count_to_id(room_id, until, Direction::Backward)
|
||||
.await?;
|
||||
let prefix = current.shortroomid();
|
||||
let stream = self
|
||||
.pduid_pdu
|
||||
|
@ -220,7 +222,7 @@ impl Data {
|
|||
pub(super) async fn pdus<'a>(
|
||||
&'a self, user_id: Option<&'a UserId>, room_id: &'a RoomId, from: PduCount,
|
||||
) -> Result<impl Stream<Item = PdusIterItem> + Send + 'a> {
|
||||
let current = self.count_to_id(room_id, from).await?;
|
||||
let current = self.count_to_id(room_id, from, Direction::Forward).await?;
|
||||
let prefix = current.shortroomid();
|
||||
let stream = self
|
||||
.pduid_pdu
|
||||
|
@ -267,7 +269,7 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
async fn count_to_id(&self, room_id: &RoomId, shorteventid: PduCount) -> Result<RawPduId> {
|
||||
async fn count_to_id(&self, room_id: &RoomId, shorteventid: PduCount, dir: Direction) -> Result<RawPduId> {
|
||||
let shortroomid: ShortRoomId = self
|
||||
.services
|
||||
.short
|
||||
|
@ -278,7 +280,7 @@ impl Data {
|
|||
// +1 so we don't send the base event
|
||||
let pdu_id = PduId {
|
||||
shortroomid,
|
||||
shorteventid,
|
||||
shorteventid: shorteventid.saturating_inc(dir),
|
||||
};
|
||||
|
||||
Ok(pdu_id.into())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue