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)]
#[serde(rename_all = "camelCase")]
pub struct Attachment {
pub name: Option<String>,
#[serde(rename = "type")]
pub attachment_type: String,
pub name: Option<String>,
pub media_type: Option<String>,
pub url: Option<String>,
}

View file

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