mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-07 04:17:39 +00:00
revert d330930bb5
revert feat: Add timestamp to event endpoint This implementation unfortunately resulted in resource exhaustion when run on some rooms.
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
mod event;
|
||||
mod initial_sync;
|
||||
mod summary;
|
||||
mod timestamp_to_event;
|
||||
mod upgrade;
|
||||
|
||||
pub(crate) use self::{
|
||||
aliases::get_room_aliases_route, create::create_room_route, event::get_room_event_route,
|
||||
initial_sync::room_initial_sync_route, summary::get_room_summary,
|
||||
timestamp_to_event::get_event_by_timestamp_route, upgrade::upgrade_room_route,
|
||||
upgrade::upgrade_room_route,
|
||||
};
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
use axum::extract::State;
|
||||
use conduwuit::{Err, Event, Result, err};
|
||||
use ruma::api::{Direction, client::room::get_event_by_timestamp};
|
||||
|
||||
use crate::Ruma;
|
||||
|
||||
/// # `GET /_matrix/client/v1/rooms/{roomId}/timestamp_to_event`
|
||||
///
|
||||
/// Gets the ID of the event closest to the given timestamp, in the direction
|
||||
/// specified by `dir`.
|
||||
pub(crate) async fn get_event_by_timestamp_route(
|
||||
State(ref services): State<crate::State>,
|
||||
body: Ruma<get_event_by_timestamp::v1::Request>,
|
||||
) -> Result<get_event_by_timestamp::v1::Response> {
|
||||
let sender_user = body.identity.expect_sender_user()?;
|
||||
let room_id = &body.room_id;
|
||||
|
||||
if !services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_see_state_events(sender_user, room_id)
|
||||
.await
|
||||
{
|
||||
return Err!(Request(Forbidden("You don't have permission to view this room.")));
|
||||
}
|
||||
|
||||
let dir = match body.dir {
|
||||
| Direction::Forward => "f",
|
||||
| Direction::Backward => "b",
|
||||
};
|
||||
|
||||
let not_found = || {
|
||||
err!(Request(NotFound(
|
||||
"Unable to find event from {} in direction {}",
|
||||
body.ts.get(),
|
||||
dir
|
||||
)))
|
||||
};
|
||||
|
||||
let Some((_, event)) = services
|
||||
.rooms
|
||||
.timeline
|
||||
.event_by_timestamp(room_id, body.ts, body.dir)
|
||||
.await
|
||||
else {
|
||||
return Err(not_found());
|
||||
};
|
||||
|
||||
if !services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_see_event(sender_user, room_id, event.event_id())
|
||||
.await
|
||||
{
|
||||
return Err!(Request(Forbidden("You don't have permission to view this event.")));
|
||||
}
|
||||
|
||||
Ok(get_event_by_timestamp::v1::Response::new(
|
||||
event.event_id().to_owned(),
|
||||
event.origin_server_ts(),
|
||||
))
|
||||
}
|
||||
@@ -52,7 +52,6 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
||||
.ruma_route(&client::set_pushrule_actions_route)
|
||||
.ruma_route(&client::delete_pushrule_route)
|
||||
.ruma_route(&client::get_room_event_route)
|
||||
.ruma_route(&client::get_event_by_timestamp_route)
|
||||
.ruma_route(&client::get_room_aliases_route)
|
||||
.ruma_route(&client::get_filter_route)
|
||||
.ruma_route(&client::create_filter_route)
|
||||
|
||||
Reference in New Issue
Block a user