From 314bca18a43e22368a87fcad53d91190fe101b60 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 7 Feb 2025 16:10:29 +0100 Subject: nodes modified since endpoint --- server/src/routes/api.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'server/src/routes/api.rs') 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 */ 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")] +pub fn r_api_nodes_modified_since( + _session: Session, + database: &State, + since: u64, +) -> MyResult>> { + 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; -- cgit v1.2.3-70-g09d2