chore: Resolve linting errors
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 4s
Release Docker Image / define-variables (push) Failing after 2s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 4s
Checks / Rust / Clippy (push) Failing after 23s
Checks / Rust / Cargo Test (push) Failing after 34s

This commit is contained in:
nexy7574 2025-07-01 18:00:28 +01:00
parent f49c73c031
commit 24d2a514e2
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
4 changed files with 29 additions and 41 deletions

22
Cargo.lock generated
View file

@ -3798,7 +3798,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.10.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -3818,7 +3818,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.10.0" version = "0.10.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3830,7 +3830,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.18.0" version = "0.18.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -3853,7 +3853,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.13.0" version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -3885,7 +3885,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.28.1" version = "0.28.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.9.0", "indexmap 2.9.0",
@ -3910,7 +3910,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"bytes", "bytes",
"headers", "headers",
@ -3932,7 +3932,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.5" version = "0.9.5"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror 2.0.12", "thiserror 2.0.12",
@ -3941,7 +3941,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3951,7 +3951,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.13.0" version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"proc-macro-crate", "proc-macro-crate",
@ -3966,7 +3966,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3978,7 +3978,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.15.0" version = "0.15.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=f899fff6738dd57d191474b0f12a4509cf8f0981#f899fff6738dd57d191474b0f12a4509cf8f0981" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=a4b948b40417a65ab0282ae47cc50035dd455e02#a4b948b40417a65ab0282ae47cc50035dd455e02"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",

View file

@ -350,7 +350,7 @@ version = "0.1.2"
[workspace.dependencies.ruma] [workspace.dependencies.ruma]
git = "https://forgejo.ellis.link/continuwuation/ruwuma" git = "https://forgejo.ellis.link/continuwuation/ruwuma"
#branch = "conduwuit-changes" #branch = "conduwuit-changes"
rev = "f899fff6738dd57d191474b0f12a4509cf8f0981" rev = "a4b948b40417a65ab0282ae47cc50035dd455e02"
features = [ features = [
"compat", "compat",
"rand", "rand",

View file

@ -1,7 +1,4 @@
use std::{ use std::{fmt::Write as _, ops::Mul, time::Duration};
ops::{Mul, Sub},
time::Duration,
};
use axum::extract::State; use axum::extract::State;
use axum_client_ip::InsecureClientIp; use axum_client_ip::InsecureClientIp;
@ -15,13 +12,7 @@ use ruma::{
report_user, report_user,
room::{report_content, report_room}, room::{report_content, report_room},
}, },
events::{ events::{Mentions, room::message::RoomMessageEventContent},
Mentions,
room::{
message,
message::{RoomMessageEvent, RoomMessageEventContent},
},
},
int, int,
}; };
use tokio::time::sleep; use tokio::time::sleep;
@ -80,10 +71,10 @@ pub(crate) async fn report_room_route(
let report = Report { let report = Report {
sender: sender_user.to_owned(), sender: sender_user.to_owned(),
room_id: Some(body.room_id.to_owned()), room_id: Some(body.room_id.clone()),
event_id: None, event_id: None,
user_id: None, user_id: None,
report_type: "room".to_string(), report_type: "room".to_owned(),
reason: body.reason.clone(), reason: body.reason.clone(),
score: None, score: None,
}; };
@ -134,10 +125,10 @@ pub(crate) async fn report_event_route(
); );
let report = Report { let report = Report {
sender: sender_user.to_owned(), sender: sender_user.to_owned(),
room_id: Some(body.room_id.to_owned()), room_id: Some(body.room_id.clone()),
event_id: Some(body.event_id.to_owned()), event_id: Some(body.event_id.clone()),
user_id: None, user_id: None,
report_type: "event".to_string(), report_type: "event".to_owned(),
reason: body.reason.clone(), reason: body.reason.clone(),
score: body.score, score: body.score,
}; };
@ -167,7 +158,7 @@ pub(crate) async fn report_user_route(
delay_response().await; delay_response().await;
if !services.users.is_active_local(&body.user_id) { if !services.users.is_active_local(&body.user_id).await {
// return 200 as to not reveal if the user exists. Recommended by spec. // return 200 as to not reveal if the user exists. Recommended by spec.
return Ok(report_user::v3::Response {}); return Ok(report_user::v3::Response {});
} }
@ -176,8 +167,8 @@ pub(crate) async fn report_user_route(
sender: sender_user.to_owned(), sender: sender_user.to_owned(),
room_id: None, room_id: None,
event_id: None, event_id: None,
user_id: Some(body.user_id.to_owned()), user_id: Some(body.user_id.clone()),
report_type: "user".to_string(), report_type: "user".to_owned(),
reason: body.reason.clone(), reason: body.reason.clone(),
score: None, score: None,
}; };
@ -255,26 +246,22 @@ fn build_report(report: Report) -> RoomMessageEventContent {
let mut text = let mut text =
format!("@room New {} report received from {}:\n\n", report.report_type, report.sender); format!("@room New {} report received from {}:\n\n", report.report_type, report.sender);
if report.user_id.is_some() { if report.user_id.is_some() {
text.push_str(&format!("- Reported User ID: `{}`\n", report.user_id.unwrap())); let _ = writeln!(text, "- Reported User ID: `{}`", report.user_id.unwrap());
} }
if report.room_id.is_some() { if report.room_id.is_some() {
text.push_str(&format!("- Reported Room ID: `{}`\n", report.room_id.unwrap())); let _ = writeln!(text, "- Reported Room ID: `{}`", report.room_id.unwrap());
} }
if report.event_id.is_some() { if report.event_id.is_some() {
text.push_str(&format!("- Reported Event ID: `{}`\n", report.event_id.unwrap())); let _ = writeln!(text, "- Reported Event ID: `{}`", report.event_id.unwrap());
} }
if let Some(score) = report.score { if let Some(score) = report.score {
if score < int!(0) { let _ = writeln!(text, "- User-supplied offensiveness score: {}%", score.mul(int!(-1)));
score.mul(int!(-1)); // invert the score to make it N/100
// unsure why the spec says -100 to 0, but 0 to 100 is more human.
}
text.push_str(&format!("- User-supplied offensiveness score: {}%\n", -score));
} }
if let Some(reason) = report.reason { if let Some(reason) = report.reason {
text.push_str(&format!("- Report Reason: {}\n", reason)); let _ = writeln!(text, "- Report Reason: {reason}");
} }
RoomMessageEventContent::text_markdown(text).add_mentions(Mentions::with_room_mention()); RoomMessageEventContent::text_markdown(text).add_mentions(Mentions::with_room_mention())
} }
/// even though this is kinda security by obscurity, let's still make a small /// even though this is kinda security by obscurity, let's still make a small

View file

@ -38,6 +38,7 @@ pub(crate) async fn get_supported_versions_route(
"v1.4".to_owned(), "v1.4".to_owned(),
"v1.5".to_owned(), "v1.5".to_owned(),
"v1.11".to_owned(), "v1.11".to_owned(),
"v1.14".to_owned(),
], ],
unstable_features: BTreeMap::from_iter([ unstable_features: BTreeMap::from_iter([
("org.matrix.e2e_cross_signing".to_owned(), true), ("org.matrix.e2e_cross_signing".to_owned(), true),