Accept attachments with type Video

Video attachments are used in PixelFed.
This commit is contained in:
silverpill 2022-12-10 18:02:08 +00:00
parent cc728afb7d
commit 64dbd8ff26
2 changed files with 10 additions and 10 deletions

View file

@ -7,11 +7,10 @@ use super::vocabulary::HASHTAG;
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Attachment { pub struct Attachment {
pub name: Option<String>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub attachment_type: String, pub attachment_type: String,
pub name: Option<String>,
pub media_type: Option<String>, pub media_type: Option<String>,
pub url: Option<String>, pub url: Option<String>,
} }

View file

@ -162,14 +162,15 @@ pub async fn handle_note(
.map_err(|_| ValidationError("invalid attachment property"))?; .map_err(|_| ValidationError("invalid attachment property"))?;
let mut downloaded = vec![]; let mut downloaded = vec![];
for attachment in list { for attachment in list {
if attachment.attachment_type != DOCUMENT && match attachment.attachment_type.as_str() {
attachment.attachment_type != IMAGE DOCUMENT | IMAGE | VIDEO => (),
{ _ => {
log::warn!( log::warn!(
"skipping attachment of type {}", "skipping attachment of type {}",
attachment.attachment_type, attachment.attachment_type,
); );
continue; continue;
},
}; };
let attachment_url = attachment.url let attachment_url = attachment.url
.ok_or(ValidationError("attachment URL is missing"))?; .ok_or(ValidationError("attachment URL is missing"))?;