From 7031240af3d92712b2594679e7a9ebcd0a2e16fc Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 14 Jun 2020 08:57:47 +0200 Subject: [PATCH] improvement: /members route --- src/client_server.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/client_server.rs b/src/client_server.rs index 0676abc..c1bb693 100644 --- a/src/client_server.rs +++ b/src/client_server.rs @@ -1743,28 +1743,28 @@ pub fn search_users_route( .into()) } -#[get("/_matrix/client/r0/rooms/<_room_id>/members")] +#[get("/_matrix/client/r0/rooms/<_room_id>/members", data = "")] pub fn get_member_events_route( db: State<'_, Database>, - //body: Ruma, + body: Ruma, _room_id: String, ) -> ConduitResult { - //let user_id = body.user_id.as_ref().expect("user is authenticated"); + let user_id = body.user_id.as_ref().expect("user is authenticated"); - //if !db.rooms.is_joined(user_id, &body.room_id)? { - // return Err(Error::BadRequest( - // ErrorKind::Forbidden, - // "You don't have permission to view this room.", - // )); - //} + if !db.rooms.is_joined(user_id, &body.room_id)? { + return Err(Error::BadRequest( + ErrorKind::Forbidden, + "You don't have permission to view this room.", + )); + } Ok(get_member_events::Response { - chunk: Vec::new(),/*db + chunk: db .rooms .room_state_type(&body.room_id, &EventType::RoomMember)? .values() .map(|pdu| pdu.to_member_event()) - .collect(),*/ + .collect(), } .into()) }