1
0
Fork 0
forked from mirror/grapevine

enable error_on_line_overflow and fix errors

These required some manual intervention.
This commit is contained in:
Charles Hall 2024-05-16 01:42:48 -07:00
parent 0afc1d2f50
commit 5cb2551422
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
6 changed files with 75 additions and 60 deletions

View file

@ -1,6 +1,7 @@
edition = "2021"
condense_wildcard_suffixes = true
error_on_line_overflow = true
format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true

View file

@ -35,58 +35,61 @@ pub(crate) async fn report_event_route(
));
};
services()
.admin
.send_message(message::RoomMessageEventContent::text_html(
format!(
"Report received from: {}\n\nEvent ID: {:?}\nRoom ID: {:?}\nSent \
By: {:?}\n\nReport Score: {:?}\nReport Reason: {:?}",
sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason
),
format!(
r#"
<details>
<summary>
Report received from:
<a href="https://matrix.to/#/{0:?}">{0:?}</a>
</summary>
<ul>
<li>
Event Info
<ul>
<li>
Event ID:
<code>{1:?}</code>
<a href="https://matrix.to/#/{2:?}/{1:?}">🔗</a>
</li>
<li>
Room ID:
<code>{2:?}</code>
</li>
<li>
Sent By:
<a href="https://matrix.to/#/{3:?}">{3:?}</a>
</li>
</ul>
</li>
<li>
Report Info
<ul>
<li>Report Score: {4:?}</li>
<li>Report Reason: {5}</li>
</ul>
</li>
</ul>
</details>
"#,
sender_user,
pdu.event_id,
pdu.room_id,
pdu.sender,
body.score,
html_escape::encode_safe(body.reason.as_deref().unwrap_or(""))
),
));
services().admin.send_message(message::RoomMessageEventContent::text_html(
format!(
"Report received from: {}\n\nEvent ID: {:?}\nRoom ID: {:?}\nSent \
By: {:?}\n\nReport Score: {:?}\nReport Reason: {:?}",
sender_user,
pdu.event_id,
pdu.room_id,
pdu.sender,
body.score,
body.reason
),
format!(
r#"
<details>
<summary>
Report received from:
<a href="https://matrix.to/#/{0:?}">{0:?}</a>
</summary>
<ul>
<li>
Event Info
<ul>
<li>
Event ID:
<code>{1:?}</code>
<a href="https://matrix.to/#/{2:?}/{1:?}">🔗</a>
</li>
<li>
Room ID:
<code>{2:?}</code>
</li>
<li>
Sent By:
<a href="https://matrix.to/#/{3:?}">{3:?}</a>
</li>
</ul>
</li>
<li>
Report Info
<ul>
<li>Report Score: {4:?}</li>
<li>Report Reason: {5}</li>
</ul>
</li>
</ul>
</details>
"#,
sender_user,
pdu.event_id,
pdu.room_id,
pdu.sender,
body.score,
html_escape::encode_safe(body.reason.as_deref().unwrap_or(""))
),
));
Ok(report_content::v3::Response {})
}

View file

@ -15,8 +15,10 @@ use super::{watchers::Watchers, KeyValueDatabaseEngine, KvTree};
use crate::{database::Config, Result};
thread_local! {
static READ_CONNECTION: RefCell<Option<&'static Connection>> = RefCell::new(None);
static READ_CONNECTION_ITERATOR: RefCell<Option<&'static Connection>> = RefCell::new(None);
static READ_CONNECTION: RefCell<Option<&'static Connection>> =
RefCell::new(None);
static READ_CONNECTION_ITERATOR: RefCell<Option<&'static Connection>> =
RefCell::new(None);
}
struct PreparedStatementIterator<'a> {

View file

@ -595,9 +595,15 @@ macro_rules! impl_ruma_handler {
for path in meta.history.all_paths() {
let handler = self.clone();
router = router.route(path, on(method_filter, |$( $ty: $ty, )* req| async move {
handler($($ty,)* req).await.map(RumaResponse)
}))
router = router.route(
path,
on(
method_filter,
|$( $ty: $ty, )* req| async move {
handler($($ty,)* req).await.map(RumaResponse)
}
)
)
}
router

View file

@ -243,7 +243,9 @@ impl Service {
Some(event) = receiver.recv() => {
let message_content = match event {
AdminRoomEvent::SendMessage(content) => content,
AdminRoomEvent::ProcessMessage(room_message) => self.process_admin_message(room_message).await
AdminRoomEvent::ProcessMessage(room_message) => {
self.process_admin_message(room_message).await
}
};
let mutex_state = Arc::clone(

View file

@ -21,6 +21,8 @@ pub(crate) struct Service {
pub(crate) db: &'static dyn Data,
}
type RoomsLeft = (OwnedRoomId, Vec<Raw<AnySyncStateEvent>>);
impl Service {
/// Update current membership data.
#[tracing::instrument(skip(self, last_state))]
@ -390,8 +392,7 @@ impl Service {
pub(crate) fn rooms_left<'a>(
&'a self,
user_id: &UserId,
) -> impl Iterator<Item = Result<(OwnedRoomId, Vec<Raw<AnySyncStateEvent>>)>> + 'a
{
) -> impl Iterator<Item = Result<RoomsLeft>> + 'a {
self.db.rooms_left(user_id)
}