mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-08 02:52:12 +00:00
update api docs, alter media file cover images
This commit is contained in:
1 parent
c4e4d8e12b
commit
67bf6e436e
3 files changed
+30
-5
No files matched your search
@@ -47,6 +47,7 @@ use crate::http_server::common_responses::media_file_social_meta_lite::MediaFile
|
||||
use crate::http_server::common_responses::media_links::*;
|
||||
use crate::http_server::common_responses::pagination_cursors::PaginationCursors;
|
||||
use crate::http_server::common_responses::pagination_page::PaginationPage;
|
||||
use crate::http_server::common_responses::media::cover_image_links::CoverImageLinks;
|
||||
use crate::http_server::common_responses::simple_entity_stats::SimpleEntityStats;
|
||||
use crate::http_server::common_responses::simple_response::SimpleResponse;
|
||||
use crate::http_server::common_responses::user_details_lite::{UserDefaultAvatarInfo, UserDetailsLight};
|
||||
@@ -305,6 +306,7 @@ use crate::http_server::web_utils::response_success_helpers::*;
|
||||
Visibility,
|
||||
|
||||
// Common cover image types
|
||||
CoverImageLinks,
|
||||
MediaFileCoverImageDetails,
|
||||
MediaFileDefaultCover,
|
||||
UserDefaultAvatarInfo,
|
||||
|
||||
+18
-5
@@ -5,6 +5,7 @@ use utoipa::ToSchema;
|
||||
|
||||
use buckets::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use crate::http_server::common_responses::media::cover_image_links::CoverImageLinks;
|
||||
use crate::http_server::common_responses::media_links::{MediaDomain, MediaLinks};
|
||||
use crate::http_server::web_utils::bucket_urls::bucket_url_from_media_path::bucket_url_from_media_path;
|
||||
|
||||
@@ -30,10 +31,17 @@ pub struct MediaFileCoverImageDetails {
|
||||
#[deprecated(note="This points to the bucket. Use media_links instead to leverage the CDN.")]
|
||||
pub maybe_cover_image_public_bucket_url: Option<Url>,
|
||||
|
||||
// NB(bt,2024-09-19): I accidentally rolled this field out to production.
|
||||
// I don't think this field is in use, but maybe ...
|
||||
// /// (DEPRECATED) Use maybe_links instead.
|
||||
// #[deprecated(note="Use `maybe_links` instead.")]
|
||||
// pub maybe_media_links: Option<MediaLinks>,
|
||||
|
||||
/// Links to the cover image (CDN direct link, thumbnail template)
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
/// If a cover image is not set, use the information in `default_cover` instead.
|
||||
/// Rich CDN links to the media, including thumbnails, previews, and more.
|
||||
pub maybe_media_links: Option<MediaLinks>,
|
||||
pub maybe_links: Option<CoverImageLinks>,
|
||||
|
||||
/// For items without a cover image, we can use one of our own.
|
||||
pub default_cover: MediaFileDefaultCover,
|
||||
@@ -59,7 +67,8 @@ impl MediaFileCoverImageDetails {
|
||||
// TODO(bt,2024-04-07): Add column to schema to support + CRUD to add.
|
||||
maybe_cover_image_public_bucket_path: None,
|
||||
maybe_cover_image_public_bucket_url: None,
|
||||
maybe_media_links: None,
|
||||
//maybe_media_links: None,
|
||||
maybe_links: None,
|
||||
default_cover: MediaFileDefaultCover::from_token_str(token),
|
||||
}
|
||||
}
|
||||
@@ -106,13 +115,17 @@ impl MediaFileCoverImageDetails {
|
||||
.map(|bucket_path| bucket_url_from_media_path(bucket_path).ok())
|
||||
.flatten();
|
||||
|
||||
let maybe_media_links = maybe_bucket_path
|
||||
.map(|path| MediaLinks::from_media_path(domain, &path));
|
||||
let maybe_links = CoverImageLinks::from_maybe_media_path(
|
||||
domain, maybe_bucket_path.as_ref());
|
||||
|
||||
// let maybe_media_links = maybe_bucket_path
|
||||
// .map(|path| MediaLinks::from_media_path(domain, &path));
|
||||
|
||||
Self {
|
||||
maybe_cover_image_public_bucket_path,
|
||||
maybe_cover_image_public_bucket_url,
|
||||
maybe_media_links,
|
||||
//maybe_media_links,
|
||||
maybe_links,
|
||||
default_cover: MediaFileDefaultCover::from_token_str(token),
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -23,6 +23,9 @@ pub struct WeightsCoverImageDetails {
|
||||
pub maybe_cover_image_public_bucket_url: Option<Url>,
|
||||
|
||||
/// Links to the cover image (CDN direct link, thumbnail template)
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
/// If a cover image is not set, use the information in `default_cover` instead.
|
||||
/// Rich CDN links to the media, including thumbnails, previews, and more.
|
||||
pub maybe_links: Option<CoverImageLinks>,
|
||||
|
||||
/// For items without a cover image, we can use one of our own.
|
||||
@@ -116,5 +119,12 @@ mod tests {
|
||||
assert_eq!(cover_image.maybe_cover_image_public_bucket_url,
|
||||
Some(Url::parse("https://storage.googleapis.com/vocodes-public/media/b/u/c/k/e/bucket_hash/image_bucket_hash.png").unwrap()));
|
||||
assert_eq!(cover_image.default_cover.image_index, 18);
|
||||
|
||||
let links = cover_image.maybe_links.unwrap();
|
||||
|
||||
assert_eq!(links.cdn_url, Url::parse(
|
||||
"https://cdn.storyteller.ai/media/b/u/c/k/e/bucket_hash/image_bucket_hash.png").unwrap());
|
||||
assert_eq!(links.thumbnail_template,
|
||||
"https://cdn.storyteller.ai/cdn-cgi/image/width={WIDTH},quality=95/media/b/u/c/k/e/bucket_hash/image_bucket_hash.png");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user