shared/domain/image/recent.rs
1//! Types for a user's recent images list. Can be from any ['MediaLibrary'](crate::media::MediaLibrary).
2//! Does not verify entries for validity/existence.
3
4use super::ImageId;
5use crate::api::endpoints::PathPart;
6use crate::media::MediaLibrary;
7use chrono::{DateTime, Utc};
8use macros::make_path_parts;
9use serde::{Deserialize, Serialize};
10use uuid::Uuid;
11
12make_path_parts!(UserRecentImageListPath => "/v1/user/me/recent/image");
13
14/// Over-the-wire representation of a single recent image.
15#[derive(Serialize, Deserialize, Debug)]
16pub struct UserRecentImageResponse {
17 /// The image's ID.
18 pub id: ImageId,
19
20 /// The library that the image belongs to.
21 pub library: MediaLibrary,
22
23 /// When the image was last used.
24 pub last_used: DateTime<Utc>,
25}
26
27make_path_parts!(UserRecentImageUpsertPath => "/v1/user/me/recent/image");
28
29/// Request to add an entry to the recent user images list,
30/// see ['recent::Put'](crate::api::endpoints::image::recent::Put).
31#[derive(Serialize, Deserialize, Debug)]
32pub struct UserRecentImageUpsertRequest {
33 /// The image's ID.
34 pub id: ImageId,
35
36 /// The library that the image belongs to.
37 pub library: MediaLibrary,
38}
39
40/// Query to list a user's recent images,
41/// see ['recent::List'](crate::api::endpoints::image::recent::List).
42///
43/// This query is optional.
44#[derive(Serialize, Deserialize, Debug)]
45pub struct UserRecentImageListRequest {
46 /// Indicates how many recent items to retrieve.
47 pub limit: u16,
48}
49
50/// Response for listing a user's recent images,
51/// see ['recent::List'](crate::api::endpoints::image::recent::List).
52#[derive(Serialize, Deserialize, Debug)]
53pub struct UserRecentImageListResponse {
54 /// The images returned.
55 pub images: Vec<UserRecentImageResponse>,
56}
57
58// uuid should be sufficient to identify an image, VERY unlikely to conflict across media libraries
59make_path_parts!(UserRecentImageDeletePath => "/v1/user/me/recent/image/{}" => Uuid);