Add attachment type "video"

This commit is contained in:
silverpill 2022-02-23 17:40:10 +00:00
parent f14e762ee3
commit 3a584f52b5
3 changed files with 24 additions and 0 deletions

View file

@ -609,6 +609,23 @@ components:
description: Ethereum wallet address. description: Ethereum wallet address.
type: string type: string
example: '0xd8da6bf...' 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: Instance:
type: object type: object
properties: properties:
@ -743,6 +760,9 @@ components:
visibility: visibility:
description: Visibility of this post. description: Visibility of this post.
$ref: '#/components/schemas/Visibility' $ref: '#/components/schemas/Visibility'
media_attachments:
description: Media that is attached to this post.
$ref: '#/components/schemas/Attachment'
mentions: mentions:
description: Mentions of users within the post. description: Mentions of users within the post.
type: array type: array

View file

@ -31,6 +31,7 @@ impl Attachment {
let attachment_type_mastodon = match attachment_type { let attachment_type_mastodon = match attachment_type {
AttachmentType::Unknown => "unknown", AttachmentType::Unknown => "unknown",
AttachmentType::Image => "image", AttachmentType::Image => "image",
AttachmentType::Video => "video",
}; };
let attachment_url = get_file_url(instance_url, &db_object.file_name); let attachment_url = get_file_url(instance_url, &db_object.file_name);
Self { Self {

View file

@ -17,6 +17,7 @@ pub struct DbMediaAttachment {
pub enum AttachmentType { pub enum AttachmentType {
Unknown, Unknown,
Image, Image,
Video,
} }
impl AttachmentType { impl AttachmentType {
@ -25,6 +26,8 @@ impl AttachmentType {
Some(media_type) => { Some(media_type) => {
if media_type.starts_with("image/") { if media_type.starts_with("image/") {
Self::Image Self::Image
} else if media_type.starts_with("video/") {
Self::Video
} else { } else {
Self::Unknown Self::Unknown
} }