aboutsummaryrefslogtreecommitdiff
path: root/server/src/ui/home.rs
blob: 96b1dc2d3beaeb514e9261fb20e2e1fbe2dde169 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
    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 <metamuffin.org>
*/
use super::{error::MyResult, node::DatabaseNodeUserDataExt};
use crate::{api::AcceptJson, database::Database, locale::AcceptLanguage, logic::session::Session};
use anyhow::Context;
use chrono::{Datelike, Utc};
use jellycommon::{api::ApiHomeResponse, user::WatchedState, NodeID, NodeKind, Rating, Visibility};
use rocket::{get, serde::json::Json, Either, State};

#[get("/home")]
pub fn r_home(
    sess: Session,
    db: &State<Database>,
    aj: AcceptJson,
    lang: AcceptLanguage,
) -> MyResult<Either<DynLayoutPage, Json<ApiHomeResponse>>> {
    let AcceptLanguage(lang) = lang;
   

    Ok(if *aj {
        Either::Right(Json(ApiHomeResponse {
            toplevel,
            categories,
        }))
    } else {
        Either::Left()
    })
}