Skip to content

Commit

Permalink
Hide code, metaprotocol, and unknown media inscriptions (ordinals#2872)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 18, 2023
1 parent f091852 commit 0dc21af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,6 @@ impl Inscription {
return true;
};

if content_type.starts_with("application/json") {
return true;
}

if content_type.starts_with("text/plain") {
return true;
}

if content_type.starts_with("text/html")
&& self
.body()
Expand All @@ -334,6 +326,14 @@ impl Inscription {
return true;
}

if self.metaprotocol.is_some() {
return true;
}

if let Media::Code(_) | Media::Text | Media::Unknown = self.media() {
return true;
}

false
}
}
Expand Down Expand Up @@ -800,7 +800,7 @@ mod tests {
}

case(None, None, true);
case(Some("foo"), None, false);
case(Some("foo"), Some(""), true);
case(Some("text/plain"), None, true);
case(
Some("text/plain"),
Expand All @@ -820,6 +820,7 @@ mod tests {
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
true,
);
case(Some("application/yaml"), Some(""), true);
case(
Some("text/html;charset=utf-8"),
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
Expand All @@ -837,5 +838,13 @@ mod tests {
..Default::default()
}
.hidden());

assert!(Inscription {
content_type: Some("text/html".as_bytes().into()),
body: Some("hello".as_bytes().into()),
metaprotocol: Some(Vec::new()),
..Default::default()
}
.hidden());
}
}
2 changes: 1 addition & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ mod tests {

for i in 0..101 {
let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(i + 1, 0, 0, inscription("foo", "hello").to_witness())],
inputs: &[(i + 1, 0, 0, inscription("image/png", "hello").to_witness())],
..Default::default()
});
ids.push(InscriptionId { txid, index: 0 });
Expand Down

0 comments on commit 0dc21af

Please sign in to comment.