shared/domain/image/
recent.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Types for a user's recent images list. Can be from any ['MediaLibrary'](crate::media::MediaLibrary).
//! Does not verify entries for validity/existence.

use super::ImageId;
use crate::api::endpoints::PathPart;
use crate::media::MediaLibrary;
use chrono::{DateTime, Utc};
use macros::make_path_parts;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

make_path_parts!(UserRecentImageListPath => "/v1/user/me/recent/image");

/// Over-the-wire representation of a single recent image.
#[derive(Serialize, Deserialize, Debug)]
pub struct UserRecentImageResponse {
    /// The image's ID.
    pub id: ImageId,

    /// The library that the image belongs to.
    pub library: MediaLibrary,

    /// When the image was last used.
    pub last_used: DateTime<Utc>,
}

make_path_parts!(UserRecentImageUpsertPath => "/v1/user/me/recent/image");

/// Request to add an entry to the recent user images list,
/// see ['recent::Put'](crate::api::endpoints::image::recent::Put).
#[derive(Serialize, Deserialize, Debug)]
pub struct UserRecentImageUpsertRequest {
    /// The image's ID.
    pub id: ImageId,

    /// The library that the image belongs to.
    pub library: MediaLibrary,
}

/// Query to list a user's recent images,
/// see ['recent::List'](crate::api::endpoints::image::recent::List).
///
/// This query is optional.
#[derive(Serialize, Deserialize, Debug)]
pub struct UserRecentImageListRequest {
    /// Indicates how many recent items to retrieve.
    pub limit: u16,
}

/// Response for listing a user's recent images,
/// see ['recent::List'](crate::api::endpoints::image::recent::List).
#[derive(Serialize, Deserialize, Debug)]
pub struct UserRecentImageListResponse {
    /// The images returned.
    pub images: Vec<UserRecentImageResponse>,
}

// uuid should be sufficient to identify an image, VERY unlikely to conflict across media libraries
make_path_parts!(UserRecentImageDeletePath => "/v1/user/me/recent/image/{}" => Uuid);