mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-27 20:45:30 +00:00
refactor: small changes
This commit is contained in:
parent
19c9e4b916
commit
325e373684
|
@ -1868,7 +1868,14 @@ pub fn get_state_events_route(
|
||||||
) -> MatrixResult<get_state_events::Response> {
|
) -> MatrixResult<get_state_events::Response> {
|
||||||
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).unwrap() {
|
if !db.rooms.is_joined(user_id, &body.room_id).unwrap() {
|
||||||
|
return MatrixResult(Err(Error {
|
||||||
|
kind: ErrorKind::Forbidden,
|
||||||
|
message: "You don't have permission to view the room state.".to_owned(),
|
||||||
|
status_code: http::StatusCode::FORBIDDEN,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
MatrixResult(Ok(get_state_events::Response {
|
MatrixResult(Ok(get_state_events::Response {
|
||||||
room_state: db
|
room_state: db
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -1878,13 +1885,6 @@ pub fn get_state_events_route(
|
||||||
.map(|pdu| pdu.to_state_event())
|
.map(|pdu| pdu.to_state_event())
|
||||||
.collect(),
|
.collect(),
|
||||||
}))
|
}))
|
||||||
} else {
|
|
||||||
MatrixResult(Err(Error {
|
|
||||||
kind: ErrorKind::Forbidden,
|
|
||||||
message: "You don't have permission to view the room state.".to_owned(),
|
|
||||||
status_code: http::StatusCode::BAD_REQUEST,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[get(
|
||||||
|
@ -1900,7 +1900,14 @@ pub fn get_state_events_for_key_route(
|
||||||
) -> MatrixResult<get_state_events_for_key::Response> {
|
) -> MatrixResult<get_state_events_for_key::Response> {
|
||||||
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).unwrap() {
|
if !db.rooms.is_joined(user_id, &body.room_id).unwrap() {
|
||||||
|
return MatrixResult(Err(Error {
|
||||||
|
kind: ErrorKind::Forbidden,
|
||||||
|
message: "You don't have permission to view the room state.".to_owned(),
|
||||||
|
status_code: http::StatusCode::FORBIDDEN,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(event) = db
|
if let Some(event) = db
|
||||||
.rooms
|
.rooms
|
||||||
.room_state(&body.room_id)
|
.room_state(&body.room_id)
|
||||||
|
@ -1914,14 +1921,7 @@ pub fn get_state_events_for_key_route(
|
||||||
MatrixResult(Err(Error {
|
MatrixResult(Err(Error {
|
||||||
kind: ErrorKind::NotFound,
|
kind: ErrorKind::NotFound,
|
||||||
message: "State event not found.".to_owned(),
|
message: "State event not found.".to_owned(),
|
||||||
status_code: http::StatusCode::BAD_REQUEST,
|
status_code: http::StatusCode::NOT_FOUND,
|
||||||
}))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MatrixResult(Err(Error {
|
|
||||||
kind: ErrorKind::Forbidden,
|
|
||||||
message: "You don't have permission to view the room state.".to_owned(),
|
|
||||||
status_code: http::StatusCode::BAD_REQUEST,
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1938,7 +1938,14 @@ pub fn get_state_events_for_empty_key_route(
|
||||||
) -> MatrixResult<get_state_events_for_key::Response> {
|
) -> MatrixResult<get_state_events_for_key::Response> {
|
||||||
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).unwrap() {
|
if !db.rooms.is_joined(user_id, &body.room_id).unwrap() {
|
||||||
|
return MatrixResult(Err(Error {
|
||||||
|
kind: ErrorKind::Forbidden,
|
||||||
|
message: "You don't have permission to view the room state.".to_owned(),
|
||||||
|
status_code: http::StatusCode::FORBIDDEN,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(event) = db
|
if let Some(event) = db
|
||||||
.rooms
|
.rooms
|
||||||
.room_state(&body.room_id)
|
.room_state(&body.room_id)
|
||||||
|
@ -1955,13 +1962,6 @@ pub fn get_state_events_for_empty_key_route(
|
||||||
status_code: http::StatusCode::BAD_REQUEST,
|
status_code: http::StatusCode::BAD_REQUEST,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MatrixResult(Err(Error {
|
|
||||||
kind: ErrorKind::Forbidden,
|
|
||||||
message: "You don't have permission to view the room state.".to_owned(),
|
|
||||||
status_code: http::StatusCode::BAD_REQUEST,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/sync", data = "<body>")]
|
#[get("/_matrix/client/r0/sync", data = "<body>")]
|
||||||
|
|
Loading…
Reference in a new issue