Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process media urls #101

Merged
merged 9 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nft_ingester/src/bubblegum_updates_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ impl BubblegumTxProcessor {
..Default::default()
}),
});

let task = Task {
ofd_metadata_url: uri.clone(),
ofd_locked_until: Some(chrono::Utc::now()),
Expand Down
33 changes: 33 additions & 0 deletions nft_ingester/src/json_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use std::sync::Arc;
use tokio::task::JoinSet;
use tokio::time::{self, Instant};

pub const JSON_CONTENT_TYPE_WITH_CHARSET: &str = "application/json; charset=utf-8";
pub const JSON_CONTENT_TYPE: &str = "application/json";

pub struct JsonDownloader {
pub db_client: Arc<DBClient>,
pub rocks_db: Arc<Storage>,
Expand Down Expand Up @@ -72,6 +75,36 @@ impl JsonDownloader {

match response {
Ok(response) => {
if let Some(content_header) = response.headers().get("Content-Type") {
if content_header != JSON_CONTENT_TYPE_WITH_CHARSET && content_header != JSON_CONTENT_TYPE {
let data_to_insert = UpdatedTask {
status: TaskStatus::Success,
metadata_url: task.metadata_url.clone(),
attempts: task.attempts + 1,
error: "".to_string(),
};
cloned_db_client
.update_tasks(vec![data_to_insert])
.await
.unwrap();

cloned_rocks
.asset_offchain_data
.put(
task.metadata_url.clone(),
OffChainData {
url: task.metadata_url,
metadata: "".to_string(),
},
)
.unwrap();

info!("Got not a JSON data from link, marked task as success...");
cloned_metrics.inc_tasks(MetricStatus::SUCCESS);
return;
}
}

if response.status() != reqwest::StatusCode::OK {
let status = {
if task.attempts >= task.max_attempts {
Expand Down
Loading