From 40f53455869d2340ab8d7aba3d1a6bed9bcbde7e Mon Sep 17 00:00:00 2001 From: strawberry Date: Wed, 17 Jan 2024 13:16:00 -0500 Subject: [PATCH] fix formatting and links of user reports more Signed-off-by: strawberry --- src/api/client_server/report.rs | 54 ++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index 85e3f543..343d9a28 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -72,32 +72,38 @@ pub async fn report_event_route( }; // send admin room message that we received the report with an @room ping for urgency - services().admin + services() + .admin .send_message(message::RoomMessageEventContent::text_html( - format!( - "@room Report received from: {}\n\n\ - Event ID: {:?}\n\ - Room ID: {:?}\n\ - Sent By: {:?}\n\n\ - Report Score: {:#?}\n\ - Report Reason: {:?}", - sender_user.to_owned(), pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason - ), - format!( - "
@room Report received from: {0}\ -
  • Event Info
  • \ - Report Info
    • Report Score: {4:?}
    • Report Reason: {5}
  • \ + format!( + "@room Report received from: {}\n\n\ + Event ID: {}\n\ + Room ID: {}\n\ + Sent By: {}\n\n\ + Report Score: {}\n\ + Report Reason: {}", + sender_user.to_owned(), + pdu.event_id, + pdu.room_id, + pdu.sender.to_owned(), + body.score.unwrap_or(ruma::Int::from(0)), + body.reason.as_deref().unwrap_or("") + ), + format!( + "
    @room Report received from: {0}\ +
    • Event Info
    • \ + Report Info
      • Report Score: {4}
      • Report Reason: {5}
    • \
    ", - sender_user.to_owned(), - pdu.event_id, - pdu.room_id, - pdu.sender, - body.score, - HtmlEscape(body.reason.as_deref().unwrap_or("")) - ), - )); + sender_user.to_owned(), + pdu.event_id.to_owned(), + pdu.room_id.to_owned(), + pdu.sender.to_owned(), + body.score.unwrap_or(ruma::Int::from(0)), + HtmlEscape(body.reason.as_deref().unwrap_or("")) + ), + )); // even though this is kinda security by obscurity, let's still make a small random delay sending a successful response // per spec suggestion regarding enumerating for potential events existing in our server.