Skip Note attachments with type other than Document
This commit is contained in:
parent
d4ab05ce1f
commit
de37f606e3
2 changed files with 13 additions and 4 deletions
|
@ -23,7 +23,7 @@ pub struct Attachment {
|
||||||
pub attachment_type: String,
|
pub attachment_type: String,
|
||||||
|
|
||||||
pub media_type: Option<String>,
|
pub media_type: Option<String>,
|
||||||
pub url: String,
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
@ -180,7 +180,7 @@ pub fn create_note(
|
||||||
name: None,
|
name: None,
|
||||||
attachment_type: DOCUMENT.to_string(),
|
attachment_type: DOCUMENT.to_string(),
|
||||||
media_type,
|
media_type,
|
||||||
url,
|
url: Some(url),
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
let mut primary_audience = vec![];
|
let mut primary_audience = vec![];
|
||||||
|
|
|
@ -226,9 +226,18 @@ pub async fn process_note(
|
||||||
let mut downloaded = vec![];
|
let mut downloaded = vec![];
|
||||||
let output_dir = config.media_dir();
|
let output_dir = config.media_dir();
|
||||||
for attachment in list {
|
for attachment in list {
|
||||||
let (file_name, media_type) = fetch_attachment(&attachment.url, &output_dir).await
|
if attachment.attachment_type != DOCUMENT {
|
||||||
|
log::warn!(
|
||||||
|
"skipping attachment of type {}",
|
||||||
|
attachment.attachment_type,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let attachment_url = attachment.url
|
||||||
|
.ok_or(ValidationError("attachment URL is missing"))?;
|
||||||
|
let (file_name, media_type) = fetch_attachment(&attachment_url, &output_dir).await
|
||||||
.map_err(|_| ValidationError("failed to fetch attachment"))?;
|
.map_err(|_| ValidationError("failed to fetch attachment"))?;
|
||||||
log::info!("downloaded attachment {}", attachment.url);
|
log::info!("downloaded attachment {}", attachment_url);
|
||||||
downloaded.push((
|
downloaded.push((
|
||||||
file_name,
|
file_name,
|
||||||
attachment.media_type.or(media_type),
|
attachment.media_type.or(media_type),
|
||||||
|
|
Loading…
Reference in a new issue