From 655f72abd5d19565f4b4c184b95e5fd4c06bed34 Mon Sep 17 00:00:00 2001 From: Martin Lindhe Date: Fri, 24 Jan 2025 11:46:28 +0100 Subject: [PATCH] rss: add field, fixes #356 --- Cargo.lock | 5 +++-- Cargo.toml | 1 + src/subreddit.rs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 819d4bc..f7f9899 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,9 +274,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "num-traits", ] @@ -1361,6 +1361,7 @@ dependencies = [ "brotli", "build_html", "cached", + "chrono", "clap", "common-words-all", "cookie", diff --git a/Cargo.toml b/Cargo.toml index a1d3ec0..14537db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ common-words-all = { version = "0.0.2", default-features = false, features = ["e hyper-rustls = { version = "0.24.2", features = [ "http2" ] } tegen = "0.1.4" serde_urlencoded = "0.7.1" +chrono = { version = "0.4.39", default-features = false, features = [ "std" ] } [dev-dependencies] diff --git a/src/subreddit.rs b/src/subreddit.rs index 88aa542..e39ed51 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -14,6 +14,7 @@ use rinja::Template; use once_cell::sync::Lazy; use regex::Regex; use time::{Duration, OffsetDateTime}; +use chrono::DateTime; // STRUCTS #[derive(Template)] @@ -499,6 +500,7 @@ pub async fn rss(req: Request) -> Result, String> { link: Some(utils::get_post_url(&post)), author: Some(post.author.name), content: Some(rewrite_urls(&post.body)), + pub_date: Some(DateTime::from_timestamp(post.created_ts as i64, 0).unwrap_or_default().to_rfc2822()), description: Some(format!( "Comments", config::get_setting("REDLIB_FULL_URL").unwrap_or_default(),