use chrono::{DateTime, Utc}; use postgres_types::FromSql; use uuid::Uuid; #[derive(Clone, FromSql)] #[postgres(name = "media_attachment")] pub struct DbMediaAttachment { pub id: Uuid, pub owner_id: Uuid, pub media_type: Option, pub file_name: String, pub post_id: Option, pub created_at: DateTime, } pub enum AttachmentType { Unknown, Image, } impl AttachmentType { pub fn from_media_type(value: Option) -> Self { match value { Some(media_type) => { if media_type.starts_with("image/") { Self::Image } else { Self::Unknown } }, None => Self::Unknown, } } }