From 49a0f3a60ddb1b707c97218e5ccc7d747b4f34a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Mon, 26 Jun 2023 08:33:31 +0200 Subject: [PATCH] fix: /context for element android. start and end must be set even with limit=0 --- src/api/client_server/context.rs | 14 ++++++++++---- src/api/server_server.rs | 3 ++- src/service/rooms/threads/mod.rs | 11 ++++------- src/service/rooms/timeline/mod.rs | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/api/client_server/context.rs b/src/api/client_server/context.rs index a824ea0f..e70f9f1e 100644 --- a/src/api/client_server/context.rs +++ b/src/api/client_server/context.rs @@ -103,7 +103,10 @@ pub async fn get_context_route( } } - let start_token = events_before.last().map(|(count, _)| count.stringify()); + let start_token = events_before + .last() + .map(|(count, _)| count.stringify()) + .unwrap_or_else(|| base_token.stringify()); let events_before: Vec<_> = events_before .into_iter() @@ -156,7 +159,10 @@ pub async fn get_context_route( .state_full_ids(shortstatehash) .await?; - let end_token = events_after.last().map(|(count, _)| count.stringify()); + let end_token = events_after + .last() + .map(|(count, _)| count.stringify()) + .unwrap_or_else(|| base_token.stringify()); let events_after: Vec<_> = events_after .into_iter() @@ -193,8 +199,8 @@ pub async fn get_context_route( } let resp = get_context::v3::Response { - start: start_token, - end: end_token, + start: Some(start_token), + end: Some(end_token), events_before, event: Some(base_event), events_after, diff --git a/src/api/server_server.rs b/src/api/server_server.rs index c1c23a5b..5e218be1 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -1,4 +1,5 @@ -#[allow(deprecated)] +#![allow(deprecated)] + use crate::{ api::client_server::{self, claim_keys_helper, get_keys_helper}, service::pdu::{gen_event_id_canonical_json, PduBuilder}, diff --git a/src/service/rooms/threads/mod.rs b/src/service/rooms/threads/mod.rs index 241927ab..fb703839 100644 --- a/src/service/rooms/threads/mod.rs +++ b/src/service/rooms/threads/mod.rs @@ -1,18 +1,15 @@ mod data; -use std::sync::Arc; pub use data::Data; use ruma::{ api::client::{error::ErrorKind, threads::get_threads::v1::IncludeThreads}, - events::{relation::BundledThread, StateEventType}, - uint, CanonicalJsonValue, EventId, OwnedUserId, RoomId, UserId, + events::relation::BundledThread, + uint, CanonicalJsonValue, EventId, RoomId, UserId, }; -use serde::Deserialize; + use serde_json::json; -use crate::{services, utils, Error, PduEvent, Result}; - -use super::timeline::PduCount; +use crate::{services, Error, PduEvent, Result}; pub struct Service { pub db: &'static dyn Data, diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 0547fcfb..625d3468 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -24,7 +24,7 @@ use ruma::{ GlobalAccountDataEventType, StateEventType, TimelineEventType, }, push::{Action, Ruleset, Tweak}, - serde::{Base64, JsonObject}, + serde::Base64, state_res, state_res::{Event, RoomVersion}, uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId,