about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/frontend/mod.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
index e142ee1..7ddad07 100644
--- a/src/frontend/mod.rs
+++ b/src/frontend/mod.rs
@@ -4,6 +4,7 @@ use axum::{
     http::{StatusCode, Uri},
     response::IntoResponse,
 };
+use axum_extra::headers::HeaderMapExt;
 use futures_util::FutureExt;
 use serde::Deserialize;
 use std::convert::TryInto;
@@ -270,6 +271,7 @@ pub async fn homepage<D: Storage>(
 
                 db.get_channels(&hcard_url).map(|i| i.unwrap_or_default())
             );
+
             if user.is_some() {
                 headers.insert(
                     axum::http::header::CACHE_CONTROL,
@@ -370,6 +372,26 @@ pub async fn catchall<D: Storage>(
                 );
             }
 
+            if post["type"][0].as_str() == Some("h-entry") {
+                let last_modified = post["properties"]["updated"]
+                    .as_array()
+                    .and_then(|v| v.last())
+                    .or_else(|| post["properties"]["published"]
+                        .as_array()
+                        .and_then(|v| v.last())
+                    )
+                    .and_then(serde_json::Value::as_str)
+                    .and_then(|dt| chrono::DateTime::<chrono::FixedOffset>::parse_from_rfc3339(dt).ok());
+
+                if let Some(last_modified) = last_modified {
+                    headers.typed_insert(
+                        axum_extra::headers::LastModified::from(
+                            std::time::SystemTime::from(last_modified)
+                        )
+                    );
+                }
+            }
+
             // Render the homepage
             (
                 StatusCode::OK,