1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-12 05:21:05 +01:00

Make reports look nicer and reduce spam potential, increase max report length to 1000 characters

This commit is contained in:
Nyaaori 2021-10-18 05:38:41 +00:00
parent ccf501a420
commit 1541b93f45
No known key found for this signature in database
GPG key ID: 50C66D0980648414

View file

@ -8,7 +8,7 @@ use ruma::{
}; };
#[cfg(feature = "conduit_bin")] #[cfg(feature = "conduit_bin")]
use rocket::post; use rocket::{http::RawStr, post};
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}` /// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
/// ///
@ -43,10 +43,10 @@ pub async fn report_event_route(
)); ));
}; };
if body.reason.chars().count() > 160 { if body.reason.chars().count() > 1000 {
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::InvalidParam, ErrorKind::InvalidParam,
"Reason too long, should be 160 characters or fewer", "Reason too long, should be 1000 characters or fewer",
)); ));
}; };
@ -61,10 +61,35 @@ pub async fn report_event_route(
let state_lock = mutex_state.lock().await; let state_lock = mutex_state.lock().await;
db.admin.send(AdminCommand::SendMessage( db.admin.send(AdminCommand::SendMessage(
message::RoomMessageEventContent::text_plain(format!( message::RoomMessageEventContent::text_html(
"Report received from: {}\r\n\r\nEvent ID: {}\r\nRoom ID: {}\r\nSent By: {}\r\n\r\nReport Score: {}\r\nReport Reason: {}", format!(
sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason, concat!(
)), "Report received from: {}\r\n\r\n",
"Event ID: {}\r\n",
"Room ID: {}\r\n",
"Sent By: {}\r\n\r\n",
"Report Score: {}\r\n",
"Report Reason: {}"
),
sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason
)
.to_owned(),
format!(
concat!(
"<details><summary>Report received from: {}</summary><details>",
"<summary>Event Info</summary><p>Event ID: {}<br>Room ID: {}<br>Sent By: {}",
"</p></details><details><summary>Report Info</summary><p>Report Score: {}",
"</br>Report Reason: {}</p></details></details>"
),
sender_user,
pdu.event_id,
pdu.room_id,
pdu.sender,
body.score,
RawStr::new(&body.reason).html_escape()
)
.to_owned(),
),
)); ));
drop(state_lock); drop(state_lock);