shared/domain/
media.rs

1//! Types for Media.
2
3use crate::api::endpoints::PathPart;
4use chrono::{DateTime, Utc};
5use macros::make_path_parts;
6use serde::{Deserialize, Serialize};
7use url::Url;
8use uuid::Uuid;
9
10use crate::media::MediaKind;
11
12make_path_parts!(MediaCreatePath => "/v1/media/image/url");
13
14/// Response for adding a URL to the Web Media Library
15#[derive(Serialize, Deserialize, Debug)]
16pub struct UrlCreatedResponse {
17    /// The ID of the media.
18    pub id: Uuid,
19
20    /// What kind of media this was inferred to be.
21    pub kind: MediaKind,
22}
23
24/// Request for adding a URL to the Web Media Library
25#[derive(Serialize, Deserialize, Debug)]
26pub struct WebMediaUrlCreateRequest {
27    /// The url.
28    pub url: Url,
29}
30
31make_path_parts!(MediaUrlGetPath => "/v1/media/url/{}" => Url);
32
33make_path_parts!(MediaIdGetPath => "/v1/media/id/{}" => Uuid);
34
35/// Response for getting metadata for media from the web media library.
36#[derive(Serialize, Deserialize, Debug)]
37pub struct WebMediaMetadataResponse {
38    /// The ID of the media
39    pub id: Uuid,
40
41    /// What kind of media this is
42    pub kind: MediaKind,
43
44    /// The urls associated with this media (can be empty)
45    pub urls: Vec<Url>,
46
47    /// When this media was added
48    pub created_at: DateTime<Utc>,
49
50    /// When this media was last updated, if ever.
51    pub updated_at: Option<DateTime<Utc>>,
52}
53
54make_path_parts!(MediaUrlDeletePath => "/v1/media/url/{}" => Url);
55
56make_path_parts!(MediaIdDeletePath => "/v1/media/id/{}" => Uuid);