mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
chore(moderation): remove the built-in NCMEC integration (#3332)
This commit is contained in:
1 parent
f390e610b9
commit
454fefdb92
146 files changed
+234
-4075
No files matched your search
@@ -957,8 +957,7 @@ fn deserialize_webhook_message_report() {
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "0000",
|
||||
"author_avatar": "a_1f2e3d",
|
||||
"webhook_id": "1556008115710000001",
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": "1556008115710000001"
|
||||
},
|
||||
{
|
||||
"id": "1556008115697091780",
|
||||
@@ -974,8 +973,7 @@ fn deserialize_webhook_message_report() {
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "6741",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
}
|
||||
]
|
||||
}));
|
||||
@@ -1164,8 +1162,7 @@ fn evidence_report_json() -> serde_json::Value {
|
||||
"width": 640,
|
||||
"height": 480,
|
||||
"size": 4096
|
||||
}],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
}]
|
||||
},
|
||||
{
|
||||
"id": "1556008115697091780",
|
||||
@@ -1183,8 +1180,7 @@ fn evidence_report_json() -> serde_json::Value {
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
}
|
||||
]
|
||||
}))
|
||||
@@ -1242,6 +1238,35 @@ fn deserialize_report_with_bot_flags_profile_snapshot_and_missing_attachments()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_report_context_with_unknown_message_and_attachment_keys() {
|
||||
let mut json = evidence_report_json();
|
||||
json["message_context"][1]["retired_list"] = serde_json::json!([]);
|
||||
json["message_context"][1]["attachments"] = serde_json::json!([{
|
||||
"id": "1556008115697091791",
|
||||
"url": "https://reports.example.test/attachments/image.png?sig=1",
|
||||
"filename": "image.png",
|
||||
"nsfw": false,
|
||||
"content_type": "image/png",
|
||||
"width": 64,
|
||||
"height": 64,
|
||||
"size": 4096,
|
||||
"retired_status": "not_submitted",
|
||||
"retired_id": null
|
||||
}]);
|
||||
let generated: generated_types::ReportAdminResponseSchema =
|
||||
serde_json::from_value(json).expect("generated report type");
|
||||
let report: types::ReportEntry =
|
||||
serde_json::from_value(serde_json::to_value(generated).expect("serialize generated"))
|
||||
.expect("hand-written report type from generated");
|
||||
let context = report.message_context.as_ref().expect("message context");
|
||||
assert_eq!(context[1]["attachments"][0]["filename"], "image.png");
|
||||
assert_eq!(
|
||||
context[1]["attachments"][0]["url"],
|
||||
"https://reports.example.test/attachments/image.png?sig=1"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_report_without_bot_flags_snapshot_or_hold() {
|
||||
let nulls = report_json(serde_json::json!({
|
||||
|
||||
@@ -429,79 +429,13 @@ async fn report_detail_renders_unknown_status_and_type_values() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ncmec_submissions_forward_the_source_report_id() {
|
||||
let received = Arc::new(Mutex::new(Vec::<Value>::new()));
|
||||
let sink = received.clone();
|
||||
let api = Router::new()
|
||||
.route(
|
||||
"/admin/messages/ncmec-reports",
|
||||
routing::post(move |Json(body): Json<Value>| {
|
||||
let sink = sink.clone();
|
||||
async move {
|
||||
sink.lock().unwrap().push(body);
|
||||
json_response(json!({
|
||||
"success": true,
|
||||
"ncmec_report_id": "ncmec-1",
|
||||
"audit_log_reason": "Submitted"
|
||||
}))
|
||||
}
|
||||
}),
|
||||
)
|
||||
.fallback(mock_api);
|
||||
let app = setup_with_api(api).await;
|
||||
let (headers, body) = get_with_headers(&app, "/messages", &[]).await;
|
||||
let csrf_token = csrf_cookie(&headers)
|
||||
.unwrap_or_else(|| panic!("messages page did not set csrf_token cookie\n{body}"));
|
||||
let cookie = format!("{}; csrf_token={}", app.session_cookie, csrf_token);
|
||||
let fields = "channel_id=1600000000000000101&message_id=1800000000000001001\
|
||||
&attachment_id=1800000000000001002&filename=image.png\
|
||||
&reporter_full_name=Casey%20Admin&confirmed_viewed=true";
|
||||
for form in [
|
||||
format!("_csrf={csrf_token}&{fields}&source_report_id=1800000000000000009"),
|
||||
format!("_csrf={csrf_token}&{fields}"),
|
||||
] {
|
||||
let (status, _, response) = post_form_with_headers(
|
||||
&app,
|
||||
"/messages?action=report-to-ncmec",
|
||||
&[("Cookie", &cookie), ("x-csrf-token", &csrf_token)],
|
||||
&form,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK, "{response}");
|
||||
assert!(response.contains("ncmec-1"), "{response}");
|
||||
}
|
||||
let received = received.lock().unwrap();
|
||||
assert_eq!(received.len(), 2, "{received:?}");
|
||||
assert_eq!(received[0]["source_report_id"], "1800000000000000009");
|
||||
assert_eq!(received[0]["attachment_id"], "1800000000000001002");
|
||||
assert_eq!(received[0]["confirmed_viewed"], true);
|
||||
assert!(
|
||||
received[1]
|
||||
.get("source_report_id")
|
||||
.is_none_or(Value::is_null),
|
||||
"{received:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn message_tools_offer_ncmec_only_with_every_required_acl() {
|
||||
let full = fluxer_admin::acl::NCMEC_ATTACHMENT_REPORT;
|
||||
let cases: [(&[&str], bool, bool); 4] = [
|
||||
(full, true, true),
|
||||
(&["*"], true, true),
|
||||
(&["csam:submit_ncmec", "message:lookup"], false, false),
|
||||
(
|
||||
&[
|
||||
"csam:submit_ncmec",
|
||||
"message:delete",
|
||||
"message:lookup",
|
||||
"user:delete",
|
||||
],
|
||||
false,
|
||||
true,
|
||||
),
|
||||
async fn message_tools_offer_delete_only_with_the_acl() {
|
||||
let cases: [(&[&str], bool); 3] = [
|
||||
(&["*"], true),
|
||||
(&["message:lookup"], false),
|
||||
(&["message:delete", "message:lookup"], true),
|
||||
];
|
||||
for (acls, ncmec, delete) in cases {
|
||||
for (acls, delete) in cases {
|
||||
let app = setup_with_api(message_tools_api(acls)).await;
|
||||
for path in [
|
||||
"/messages?channel_id=1600000000000000101&message_id=1800000000000001001",
|
||||
@@ -509,20 +443,11 @@ async fn message_tools_offer_ncmec_only_with_every_required_acl() {
|
||||
] {
|
||||
let body = get(&app, path, &[]).await;
|
||||
assert!(body.contains("tools-image.png"), "{acls:?} {path}\n{body}");
|
||||
assert_eq!(
|
||||
body.contains(r#"class="ncmec-report-btn"#),
|
||||
ncmec,
|
||||
"{acls:?} {path}\n{body}"
|
||||
);
|
||||
assert_eq!(
|
||||
body.contains(r#"class="delete-message-btn"#),
|
||||
delete,
|
||||
"{acls:?} {path}\n{body}"
|
||||
);
|
||||
assert!(
|
||||
!body.contains("data-source-report-id"),
|
||||
"{acls:?} {path}\n{body}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -682,8 +607,7 @@ fn evidence_report() -> Value {
|
||||
"width": 640,
|
||||
"height": 480,
|
||||
"size": 4096
|
||||
}],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
}]
|
||||
},
|
||||
{
|
||||
"id": "1800000000000000999",
|
||||
@@ -701,8 +625,7 @@ fn evidence_report() -> Value {
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -1890,10 +1813,7 @@ fn message_tools_api(acls: &[&str]) -> Router {
|
||||
"content_type": "image/png",
|
||||
"width": 64,
|
||||
"height": 64,
|
||||
"size": 4096,
|
||||
"ncmec_status": "not_submitted",
|
||||
"ncmec_report_id": null,
|
||||
"ncmec_failure_reason": null
|
||||
"size": 4096
|
||||
}]
|
||||
});
|
||||
let lookup = json!({"messages": [message.clone()], "message_id": "1800000000000001001"});
|
||||
|
||||
@@ -80,8 +80,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159119835293",
|
||||
@@ -104,8 +103,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159124029598",
|
||||
@@ -128,8 +126,7 @@
|
||||
"author_avatar": "f829b914",
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159128223903",
|
||||
@@ -152,8 +149,7 @@
|
||||
"author_avatar": "f829b914",
|
||||
"webhook_id": null,
|
||||
"author_bot": false,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159140806818",
|
||||
@@ -176,8 +172,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": "1556352159132418208",
|
||||
"author_bot": null,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159153389733",
|
||||
@@ -200,8 +195,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": true,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159161778343",
|
||||
@@ -224,8 +218,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": true,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159212110003",
|
||||
@@ -248,8 +241,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": "1556352159203721393",
|
||||
"author_bot": null,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
},
|
||||
{
|
||||
"id": "1556352159186944173",
|
||||
@@ -272,8 +264,7 @@
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"author_bot": null,
|
||||
"missing_attachments": [],
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"missing_attachments": []
|
||||
}
|
||||
],
|
||||
"message_responses": [
|
||||
|
||||
@@ -77,8 +77,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "7915",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449163617486",
|
||||
@@ -99,8 +98,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "0943",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449167811791",
|
||||
@@ -121,8 +119,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "9014",
|
||||
"author_avatar": "f829b914",
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449172006096",
|
||||
@@ -143,8 +140,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "9014",
|
||||
"author_avatar": "f829b914",
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449184589011",
|
||||
@@ -165,8 +161,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "0000",
|
||||
"author_avatar": null,
|
||||
"webhook_id": "1556114449176200401",
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": "1556114449176200401"
|
||||
},
|
||||
{
|
||||
"id": "1556114449255892196",
|
||||
@@ -187,8 +182,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "0000",
|
||||
"author_avatar": null,
|
||||
"webhook_id": "1556114449247503586",
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": "1556114449247503586"
|
||||
},
|
||||
{
|
||||
"id": "1556114449230726366",
|
||||
@@ -209,8 +203,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "0000",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449205560536",
|
||||
@@ -231,8 +224,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "1238",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
},
|
||||
{
|
||||
"id": "1556114449197171926",
|
||||
@@ -253,8 +245,7 @@
|
||||
"author_global_name": null,
|
||||
"author_discriminator": "1238",
|
||||
"author_avatar": null,
|
||||
"webhook_id": null,
|
||||
"user_prior_ncmec_report_ids": []
|
||||
"webhook_id": null
|
||||
}
|
||||
],
|
||||
"message_responses": [
|
||||
|
||||
Reference in new issue
Block a user