From 1cfdd07d40f40061daca7ff9b76dc86e27ccfc5e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Sep 2021 10:15:38 -0700 Subject: [PATCH] Avoid fetching GH releases in home route Co-Authored-By: Antonio Scandurra --- server/src/home.rs | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/server/src/home.rs b/server/src/home.rs index 10336f2fb7..69bee449a8 100644 --- a/server/src/home.rs +++ b/server/src/home.rs @@ -1,8 +1,5 @@ -use crate::{ - auth::RequestExt as _, github::Release, AppState, LayoutData, Request, RequestExt as _, -}; -use comrak::ComrakOptions; -use serde::{Deserialize, Serialize}; +use crate::{AppState, Request, RequestExt as _}; +use serde::Deserialize; use std::sync::Arc; use tide::{http::mime, log, Server}; @@ -13,42 +10,7 @@ pub fn add_routes(app: &mut Server>) { } async fn get_home(mut request: Request) -> tide::Result { - #[derive(Serialize)] - struct HomeData { - #[serde(flatten)] - layout: Arc, - releases: Option>, - } - - let mut data = HomeData { - layout: request.layout_data().await?, - releases: None, - }; - - if let Some(user) = request.current_user().await? { - if user.is_insider { - data.releases = Some( - request - .state() - .repo_client - .releases() - .await? - .into_iter() - .filter_map(|mut release| { - if release.draft { - None - } else { - let mut options = ComrakOptions::default(); - options.render.unsafe_ = true; // Allow raw HTML in the markup. We control these release notes anyway. - release.body = comrak::markdown_to_html(&release.body, &options); - Some(release) - } - }) - .collect(), - ); - } - } - + let data = request.layout_data().await?; Ok(tide::Response::builder(200) .body(request.state().render_template("home.hbs", &data)?) .content_type(mime::HTML) @@ -114,4 +76,4 @@ async fn get_release_asset(request: Request) -> tide::Result { .content_type(mime::BYTE_STREAM) .body(body) .build()) -} \ No newline at end of file +}