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)
.await
.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) {
return Ok(build_response(
StatusCode::NOT_FOUND,
@@ -439,33 +446,24 @@ impl ApiHandler {
hyper::Body::from("Content not found"),
));
}
let price_sats = match catalog.items.iter().find(|i| i.id == content_id) {
Some(i) => match &i.access {
content_server::AccessControl::Paid { price_sats, .. } => {
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
}
_ => {
let price_sats = match &item.access {
content_server::AccessControl::Paid { price_sats, .. } => {
if !content_server::method_accepted(&item.access, "onchain") {
return Ok(build_response(
StatusCode::BAD_REQUEST,
"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"}"#,
),
));
}
},
None => {
*price_sats
}
_ => {
return Ok(build_response(
StatusCode::NOT_FOUND,
"text/plain",
hyper::Body::from("Content not found"),
StatusCode::BAD_REQUEST,
"application/json",
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 ;;
esac
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'
import json,sys
for line in open(sys.argv[1]):