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
|
/*
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;
let resp = jellylogic::home::home(&db, sess)?;
Ok(if *aj {
Either::Right(Json(resp))
} else {
Either::Left(jellyui::home::home_page(resp))
})
}
|