diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-07 16:10:29 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-07 16:10:29 +0100 |
commit | 314bca18a43e22368a87fcad53d91190fe101b60 (patch) | |
tree | 3cf89e2a6904c5a6abae8fe92a5a3aa96501a63c /server/src/routes/api.rs | |
parent | 346095d20e3d817d150cbea49e87a49fbcaa2304 (diff) | |
download | jellything-314bca18a43e22368a87fcad53d91190fe101b60.tar jellything-314bca18a43e22368a87fcad53d91190fe101b60.tar.bz2 jellything-314bca18a43e22368a87fcad53d91190fe101b60.tar.zst |
nodes modified since endpoint
Diffstat (limited to 'server/src/routes/api.rs')
-rw-r--r-- | server/src/routes/api.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/server/src/routes/api.rs b/server/src/routes/api.rs index f761a8f..4e2211f 100644 --- a/server/src/routes/api.rs +++ b/server/src/routes/api.rs @@ -4,12 +4,15 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ use super::ui::{ - account::{login_logic, session::AdminSession}, + account::{ + login_logic, + session::{AdminSession, Session}, + }, error::MyResult, }; use crate::database::Database; use jellybase::assetfed::AssetInner; -use jellycommon::user::CreateSessionParams; +use jellycommon::{user::CreateSessionParams, NodeID, Visibility}; use rocket::{ get, http::MediaType, @@ -53,6 +56,22 @@ pub fn r_api_asset_token_raw(_admin: AdminSession, token: &str) -> MyResult<Json Ok(Json(AssetInner::deser(token)?)) } +#[get("/api/nodes_modified?<since>")] +pub fn r_api_nodes_modified_since( + _session: Session, + database: &State<Database>, + since: u64, +) -> MyResult<Json<Vec<NodeID>>> { + let mut nodes = database.get_nodes_modified_since(since)?; + nodes.retain(|id| { + database.get_node(*id).map_or(false, |n| { + n.as_ref() + .map_or(false, |n| n.visibility >= Visibility::Reduced) + }) + }); + Ok(Json(nodes)) +} + pub struct AcceptJson(bool); impl Deref for AcceptJson { type Target = bool; |