/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ use super::{ error::MyResult, layout::{trs, DynLayoutPage, LayoutPage}, node::{DatabaseNodeUserDataExt, NodeCard}, }; use crate::{api::AcceptJson, locale::AcceptLanguage, logic::session::Session}; use anyhow::anyhow; use jellybase::{database::Database, locale::tr}; use jellycommon::{api::ApiSearchResponse, Visibility}; use rocket::{get, serde::json::Json, Either, State}; use std::time::Instant; #[get("/search?&")] pub async fn r_search<'a>( session: Session, db: &State, aj: AcceptJson, query: Option<&str>, page: Option, lang: AcceptLanguage, ) -> MyResult, Json>> { let AcceptLanguage(lang) = lang; Ok(if *aj { let Some((count, results, _)) = results else { Err(anyhow!("no query"))? }; Either::Right(Json(ApiSearchResponse { count, results })) } else { Either::Left() }) }