Check on-chain item visibility and reduce test debug-data pressure

This commit is contained in:
archipelago
2026-10-06 06:17:49 -04:00
parent 744923f7d3
commit 8ffbf5ff6e
2 changed files with 21 additions and 23 deletions
+20 -22
View File
@@ -432,6 +432,13 @@ impl ApiHandler {
let catalog = content_server::load_catalog(&self.config.data_dir) let catalog = content_server::load_catalog(&self.config.data_dir)
.await .await
.unwrap_or_default(); .unwrap_or_default();
let Some(item) = catalog.items.iter().find(|item| item.id == content_id) else {
return Ok(build_response(
StatusCode::NOT_FOUND,
"text/plain",
hyper::Body::from("Content not found"),
));
};
if !content_server::visible_to(item, peer.as_deref(), known, owner) { if !content_server::visible_to(item, peer.as_deref(), known, owner) {
return Ok(build_response( return Ok(build_response(
StatusCode::NOT_FOUND, StatusCode::NOT_FOUND,
@@ -439,33 +446,24 @@ impl ApiHandler {
hyper::Body::from("Content not found"), hyper::Body::from("Content not found"),
)); ));
} }
let price_sats = match catalog.items.iter().find(|i| i.id == content_id) { let price_sats = match &item.access {
Some(i) => match &i.access { content_server::AccessControl::Paid { price_sats, .. } => {
content_server::AccessControl::Paid { price_sats, .. } => { if !content_server::method_accepted(&item.access, "onchain") {
if !content_server::method_accepted(&i.access, "onchain") {
return Ok(build_response(
StatusCode::BAD_REQUEST,
"application/json",
hyper::Body::from(
r#"{"error":"The seller does not accept on-chain payment for this item"}"#,
),
));
}
*price_sats
}
_ => {
return Ok(build_response( return Ok(build_response(
StatusCode::BAD_REQUEST, StatusCode::BAD_REQUEST,
"application/json", "application/json",
hyper::Body::from(r#"{"error":"Item is not paid"}"#), hyper::Body::from(
)) r#"{"error":"The seller does not accept on-chain payment for this item"}"#,
),
));
} }
}, *price_sats
None => { }
_ => {
return Ok(build_response( return Ok(build_response(
StatusCode::NOT_FOUND, StatusCode::BAD_REQUEST,
"text/plain", "application/json",
hyper::Body::from("Content not found"), hyper::Body::from(r#"{"error":"Item is not paid"}"#),
)) ))
} }
}; };
+1 -1
View File
@@ -15,7 +15,7 @@ case "${ARCHY_TEST_PACKAGE:-archipelago}" in
*) echo 'Unsupported isolated test package' >&2; exit 2 ;; *) echo 'Unsupported isolated test package' >&2; exit 2 ;;
esac esac
if ! cargo test --manifest-path "$REPO/core/Cargo.toml" "${test_target[@]}" \ if ! cargo test --manifest-path "$REPO/core/Cargo.toml" "${test_target[@]}" \
--locked --no-run --message-format=json --config 'profile.test.package.archipelago.opt-level=0' > "$metadata"; then --locked --no-run --message-format=json --config 'profile.test.package.archipelago.opt-level=0' --config 'profile.test.package.archipelago.debug=0' > "$metadata"; then
python3 - "$metadata" <<'PYDIAG' python3 - "$metadata" <<'PYDIAG'
import json,sys import json,sys
for line in open(sys.argv[1]): for line in open(sys.argv[1]):