From 3a584f52b5e0dc501c3ce5ee9895fb40e6f84c0b Mon Sep 17 00:00:00 2001 From: silverpill Date: Wed, 23 Feb 2022 17:40:10 +0000 Subject: [PATCH] Add attachment type "video" --- docs/openapi.yaml | 20 ++++++++++++++++++++ src/mastodon_api/media/types.rs | 1 + src/models/attachments/types.rs | 3 +++ 3 files changed, 24 insertions(+) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 4bc421c..35ee941 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -609,6 +609,23 @@ components: description: Ethereum wallet address. type: string example: '0xd8da6bf...' + Attachment: + type: object + properties: + id: + description: The ID of the attachment in the database. + type: string + format: uuid + type: + description: The type of the attachment. + type: string + enum: + - unknown + - image + - video + url: + description: The location of the original full-size attachment. + type: string Instance: type: object properties: @@ -743,6 +760,9 @@ components: visibility: description: Visibility of this post. $ref: '#/components/schemas/Visibility' + media_attachments: + description: Media that is attached to this post. + $ref: '#/components/schemas/Attachment' mentions: description: Mentions of users within the post. type: array diff --git a/src/mastodon_api/media/types.rs b/src/mastodon_api/media/types.rs index 5d320c6..6fc5744 100644 --- a/src/mastodon_api/media/types.rs +++ b/src/mastodon_api/media/types.rs @@ -31,6 +31,7 @@ impl Attachment { let attachment_type_mastodon = match attachment_type { AttachmentType::Unknown => "unknown", AttachmentType::Image => "image", + AttachmentType::Video => "video", }; let attachment_url = get_file_url(instance_url, &db_object.file_name); Self { diff --git a/src/models/attachments/types.rs b/src/models/attachments/types.rs index a479a19..756ceca 100644 --- a/src/models/attachments/types.rs +++ b/src/models/attachments/types.rs @@ -17,6 +17,7 @@ pub struct DbMediaAttachment { pub enum AttachmentType { Unknown, Image, + Video, } impl AttachmentType { @@ -25,6 +26,8 @@ impl AttachmentType { Some(media_type) => { if media_type.starts_with("image/") { Self::Image + } else if media_type.starts_with("video/") { + Self::Video } else { Self::Unknown }