Skip to content

Commit

Permalink
Fix content type (#35)
Browse files Browse the repository at this point in the history
* Fix content type

* Bump version
  • Loading branch information
nothing0012 authored Nov 5, 2023
1 parent 281a669 commit 95075f6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ord"
description = "◉ Ordinal wallet and block explorer"
version = "7.1.2"
version = "7.2.1"
license = "CC0-1.0"
edition = "2021"
autotests = false
Expand Down
36 changes: 27 additions & 9 deletions src/index/updater/inscription_updater/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,30 @@ impl StreamEvent {
Network::from_str(&env::var("NETWORK").unwrap_or("bitcoin".to_owned())).unwrap()
}

fn is_text_related(media: Media, content_type: Option<String>) -> bool {
if content_type
.map(|ct| ct.starts_with("text/") || ct.starts_with("image/svg"))
.unwrap_or(false)
{
return true;
}

// check if inscription.media() is within a list of streamable media
match media {
Media::Text => true,
Media::Code => true,
Media::Iframe => true,
Media::Markdown => true,

Media::Image => false,
Media::Model => false,
Media::Pdf => false,
Media::Unknown => false,
Media::Video => false,
Media::Audio => false,
}
}

fn enrich_content(&mut self, inscription: Inscription) -> &mut Self {
self.metaprotocol = inscription.metaprotocol().map(|mp| mp.to_owned());
self.metadata = inscription.metadata();
Expand All @@ -248,15 +272,9 @@ impl StreamEvent {
.parse::<usize>()
.unwrap();

// Text Media and Content-Type starting with "text/" are included with the content-body payload
let is_text = inscription.media() == Media::Text
|| self
.content_type
.clone()
.map(|ct| ct.starts_with("text/") || ct.starts_with("image/svg"))
.unwrap_or(false);

if is_text && body.len() < kafka_body_max_bytes {
if Self::is_text_related(inscription.media(), self.content_type.clone())
&& body.len() < kafka_body_max_bytes
{
self.brc20 = serde_json::from_slice(body).unwrap_or(None);
self.domain = Domain::parse(body);
Some(general_purpose::STANDARD.encode(body))
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/server/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn get_palindromes_from_equal_length_range(start_string: String, end_string: Str

let get_palindrome = |sig_digits: &str| -> u64 {
let palindrome_string = sig_digits.to_string()
+ &sig_digits.chars().rev().collect::<String>()[middle_digit_exists as usize..];
+ &sig_digits.chars().rev().collect::<String>()[usize::from(middle_digit_exists)..];
palindrome_string.parse::<u64>().unwrap()
};

Expand Down

0 comments on commit 95075f6

Please sign in to comment.