diff options
author | cel 🌸 <cel@blos.sm> | 2023-06-20 16:02:12 +0100 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-06-20 16:02:12 +0100 |
commit | 27baf0ab8005eed210a34d87a1c1f10b3f351d75 (patch) | |
tree | ca34782b1ef225583c68378f367ea4ba31eebc44 /src/main.rs | |
parent | 5de43f2c45e02396cfe46f5b8a3a00453efd8c4a (diff) | |
download | blossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.tar.gz blossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.tar.bz2 blossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.zip |
add is_live check
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index ab65f8e..57d4973 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod error; +mod live; mod posts; mod scrobbles; mod skweets; @@ -17,27 +18,30 @@ type Result<T> = std::result::Result<T, BlossomError>; struct Clients { listenbrainz: listenbrainz::raw::Client, skinnyverse: mastodon_async::Mastodon, + reqwest: reqwest::Client, } #[macro_use] extern crate rocket; #[get("/")] -async fn home(clients: &State<Clients>) -> Result<Template> { - let (listenbrainz, skweets) = tokio::join!( +async fn home(clients: &State<Clients>) -> Template { + let (live, listenbrainz, skweets) = tokio::join!( + live::get_live_status(&clients.reqwest), scrobbles::get_now_playing(&clients.listenbrainz), skweets::get_recents(&clients.skinnyverse) ); + let is_live = live.unwrap_or_default().online; let listenbrainz = listenbrainz.unwrap_or_default(); let skweets = skweets.unwrap_or_default(); - Ok(Template::render( + Template::render( "home", context! { - is_live: false, + is_live, listenbrainz, skweets, }, - )) + ) } #[get("/contact")] @@ -78,6 +82,7 @@ async fn main() -> std::result::Result<(), rocket::Error> { .manage(Clients { listenbrainz: listenbrainz::raw::Client::new(), skinnyverse: mastodon_async::Mastodon::from(skinny_data), + reqwest: reqwest::Client::new(), }) .attach(Template::custom(|engines| { engines.tera.autoescape_on(vec![]); |