From ebb36235a70a2c539a7656454de3478ae776aa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 30 Jan 2020 22:30:57 +0100 Subject: [PATCH] Cache icons in the clients --- src/api/icons.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/icons.rs b/src/api/icons.rs index 6dd0619d..556395ee 100644 --- a/src/api/icons.rs +++ b/src/api/icons.rs @@ -16,6 +16,7 @@ use soup::prelude::*; use crate::error::Error; use crate::CONFIG; +use crate::util::Cached; pub fn routes() -> Vec { routes![icon] @@ -53,15 +54,15 @@ fn is_valid_domain(domain: &str) -> bool { } #[get("//icon.png")] -fn icon(domain: String) -> Content> { +fn icon(domain: String) -> Cached>> { let icon_type = ContentType::new("image", "x-icon"); if !is_valid_domain(&domain) { warn!("Invalid domain: {:#?}", domain); - return Content(icon_type, FALLBACK_ICON.to_vec()); + return Cached::long(Content(icon_type, FALLBACK_ICON.to_vec())); } - Content(icon_type, get_icon(&domain)) + Cached::long(Content(icon_type, get_icon(&domain))) } fn check_icon_domain_is_blacklisted(domain: &str) -> bool {