Can redact message
This commit is contained in:
@@ -83,7 +83,7 @@ pub async fn get_for_room(
|
||||
path: web::Path<RoomIdInPath>,
|
||||
query: web::Query<GetRoomEventsQuery>,
|
||||
) -> HttpResult {
|
||||
let Some(room) = client.client.client.get_room(&path.id) else {
|
||||
let Some(room) = client.client.client.get_room(&path.room_id) else {
|
||||
return Ok(HttpResponse::NotFound().json("Room not found!"));
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ pub async fn send_text_message(
|
||||
) -> HttpResult {
|
||||
let req = client.auth.decode_json_body::<SendTextMessageRequest>()?;
|
||||
|
||||
let Some(room) = client.client.client.get_room(&path.id) else {
|
||||
let Some(room) = client.client.client.get_room(&path.room_id) else {
|
||||
return Ok(HttpResponse::NotFound().json("Room not found!"));
|
||||
};
|
||||
|
||||
@@ -111,3 +111,27 @@ pub async fn send_text_message(
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct EventIdInPath {
|
||||
pub(crate) event_id: OwnedEventId,
|
||||
}
|
||||
|
||||
pub async fn redact_event(
|
||||
client: MatrixClientExtractor,
|
||||
path: web::Path<RoomIdInPath>,
|
||||
event_path: web::Path<EventIdInPath>,
|
||||
) -> HttpResult {
|
||||
let Some(room) = client.client.client.get_room(&path.room_id) else {
|
||||
return Ok(HttpResponse::NotFound().json("Room not found!"));
|
||||
};
|
||||
|
||||
Ok(match room.redact(&event_path.event_id, None, None).await {
|
||||
Ok(_) => HttpResponse::Accepted().finish(),
|
||||
|
||||
Err(e) => {
|
||||
log::error!("Failed to redact event {}: {e}", event_path.event_id);
|
||||
HttpResponse::InternalServerError().json(format!("Failed to redact event! {e}"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user