aboutsummaryrefslogtreecommitdiff
path: root/common/src/api.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-22 03:25:26 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-22 03:25:26 +0100
commit10cdaaa30a6b4a187797434dc8d959780f0e8fbf (patch)
tree6c050b5cfec8a06de09fc4eb8ce5d20ff761a169 /common/src/api.rs
parentda27cc2f457f362f11f65b4e06e3d9eca09d1344 (diff)
downloadjellything-10cdaaa30a6b4a187797434dc8d959780f0e8fbf.tar
jellything-10cdaaa30a6b4a187797434dc8d959780f0e8fbf.tar.bz2
jellything-10cdaaa30a6b4a187797434dc8d959780f0e8fbf.tar.zst
start on typedef for renderer types
Diffstat (limited to 'common/src/api.rs')
-rw-r--r--common/src/api.rs185
1 files changed, 81 insertions, 104 deletions
diff --git a/common/src/api.rs b/common/src/api.rs
index 0dc8f43..2123477 100644
--- a/common/src/api.rs
+++ b/common/src/api.rs
@@ -3,120 +3,97 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use crate::user::{NodeUserData, User};
-use std::{collections::BTreeMap, sync::Arc, time::Duration};
-pub struct ApiNodeResponse {
- pub parents: NodesWithUdata,
- pub children: NodesWithUdata,
- pub node: Arc<Node>,
- pub userdata: NodeUserData,
-}
+use jellyobject::{Object, Tag, enums, fields};
-pub struct ApiSearchResponse {
- pub count: usize,
- pub results: NodesWithUdata,
- pub duration: Duration,
-}
+fields! {
+ QUERY_PARENT: u64 = 2000 "parent";
+ QUERY_SEARCH: &str = 2001 "search";
+ QUERY_KIND: Tag = 2004 "kind"; // multi
+ QUERY_SORT: Tag = 2002 "sort"; // one of RTYP_*, NU_RATING, NO_DURATION, NO_NAME
+ QUERY_SORT_ASCENDING: () = 2003 "sort_ascending";
-pub struct ApiItemsResponse {
- pub count: usize,
- pub pages: usize,
- pub items: NodesWithUdata,
-}
+ VIEW_TITLE: &str = 2005 "title";
+ VIEW_MESSAGE: &str = 2010 "message";
+ VIEW_NODE_PAGE: Object = 2011 "node_page";
+ VIEW_NODE_LIST: Object = 2012 "node_list"; // multi
+ VIEW_PLAYER: u64 = 2028 "player";
-pub struct ApiHomeResponse {
- pub toplevel: NodesWithUdata,
- pub categories: Vec<(String, NodesWithUdata)>,
-}
+ NKU_NODE: Object = 2025 "node";
+ NKU_UDATA: Object = 2026 "udata";
+ NKU_ROLE: &str = 2027 "role";
-pub struct ApiStatsResponse {
- pub kinds: BTreeMap<NodeKind, StatsBin>,
- pub total: StatsBin,
+ NODELIST_TITLE: &str = 2007 "title";
+ NODELIST_DISPLAYSTYLE: &str = 2008 "displaystyle";
+ NODELIST_ITEM: &str = 2009 "item";
}
-pub struct ApiAdminUsersResponse {
- pub users: Vec<User>,
+enums! {
+ NLSTYLE_GRID = 1023 "grid";
+ NLSTYLE_INLINE = 1024 "inline";
+ NLSTYLE_LIST = 1023 "list";
}
-pub struct LogLine {
- pub time: DateTime<Utc>,
- pub module: Option<&'static str>,
- pub level: LogLevel,
- pub message: String,
-}
+// use crate::user::{NodeUserData, User};
+// use std::{collections::BTreeMap, sync::Arc, time::Duration};
+// pub struct ApiNodeResponse {
+// pub parents: NodesWithUdata,
+// pub children: NodesWithUdata,
+// pub node: Arc<Node>,
+// pub userdata: NodeUserData,
+// }
-url_enum!(
- #[derive(Serialize, Deserialize, Clone, Copy, PartialEq)]
- enum LogLevel {
- Trace = "trace",
- Debug = "debug",
- Info = "info",
- Warn = "warn",
- Error = "error",
- }
-);
+// pub struct ApiSearchResponse {
+// pub count: usize,
+// pub results: NodesWithUdata,
+// pub duration: Duration,
+// }
-#[derive(Default, Serialize, Deserialize)]
-pub struct StatsBin {
- pub runtime: f64,
- pub size: u64,
- pub count: usize,
- pub max_runtime: f64,
- pub max_runtime_node: String,
- pub max_size: u64,
- pub max_size_node: String,
-}
+// pub struct ApiItemsResponse {
+// pub count: usize,
+// pub pages: usize,
+// pub items: NodesWithUdata,
+// }
-#[derive(Debug, Default, Clone)]
-pub struct NodeFilterSort {
- pub sort_by: Option<SortProperty>,
- pub filter_kind: Option<Vec<FilterProperty>>,
- pub sort_order: Option<SortOrder>,
-}
+// pub struct ApiHomeResponse {
+// pub toplevel: NodesWithUdata,
+// pub categories: Vec<(String, NodesWithUdata)>,
+// }
+
+// pub struct ApiStatsResponse {
+// pub kinds: BTreeMap<NodeKind, StatsBin>,
+// pub total: StatsBin,
+// }
+
+// pub struct ApiAdminUsersResponse {
+// pub users: Vec<User>,
+// }
+
+// pub struct LogLine {
+// pub time: DateTime<Utc>,
+// pub module: Option<&'static str>,
+// pub level: LogLevel,
+// pub message: String,
+// }
+
+// url_enum!(
+// #[derive(Serialize, Deserialize, Clone, Copy, PartialEq)]
+// enum LogLevel {
+// Trace = "trace",
+// Debug = "debug",
+// Info = "info",
+// Warn = "warn",
+// Error = "error",
+// }
+// );
-url_enum!(
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
- enum FilterProperty {
- FederationLocal = "fed_local",
- FederationRemote = "fed_remote",
- Watched = "watched",
- Unwatched = "unwatched",
- WatchProgress = "watch_progress",
- KindMovie = "kind_movie",
- KindVideo = "kind_video",
- KindShortFormVideo = "kind_short_form_video",
- KindMusic = "kind_music",
- KindCollection = "kind_collection",
- KindChannel = "kind_channel",
- KindShow = "kind_show",
- KindSeries = "kind_series",
- KindSeason = "kind_season",
- KindEpisode = "kind_episode",
- }
-);
-url_enum!(
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
- enum SortProperty {
- ReleaseDate = "release_date",
- Title = "title",
- Index = "index",
- Duration = "duration",
- RatingRottenTomatoes = "rating_rt",
- RatingMetacritic = "rating_mc",
- RatingImdb = "rating_imdb",
- RatingTmdb = "rating_tmdb",
- RatingYoutubeViews = "rating_yt_views",
- RatingYoutubeLikes = "rating_yt_likes",
- RatingYoutubeFollowers = "rating_yt_followers",
- RatingUser = "rating_user",
- RatingLikesDivViews = "rating_loved",
- }
-);
-url_enum!(
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
- enum SortOrder {
- Ascending = "ascending",
- Descending = "descending",
- }
-);
+// #[derive(Default, Serialize, Deserialize)]
+// pub struct StatsBin {
+// pub runtime: f64,
+// pub size: u64,
+// pub count: usize,
+// pub max_runtime: f64,
+// pub max_runtime_node: String,
+// pub max_size: u64,
+// pub max_size_node: String,
+// }