Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: 9b3c88ee4e6a1f0fec712157982c3a358b3ac463
Timestamp: Sat, 30 Dec 2023 09:25:58 +0000 (1 year ago)

+13 -2 +/-1 browse
add missing guid for summary items in rss
1diff --git a/src/web2/routes/rss.rs b/src/web2/routes/rss.rs
2index 78637aa..737050e 100644
3--- a/src/web2/routes/rss.rs
4+++ b/src/web2/routes/rss.rs
5 @@ -7,7 +7,7 @@ use axum::{
6 response::Response,
7 };
8 use mime::TEXT_XML;
9- use rss::{Channel, Item};
10+ use rss::{Channel, Guid, Item};
11 use serde::Serialize;
12 use tera::{Context, Tera};
13 use time::{format_description::well_known::Rfc2822, macros::time, Duration, OffsetDateTime};
14 @@ -189,7 +189,7 @@ impl Builder {
15 item.set_title(format!("Commit: {}", commit.summary));
16 item.set_author(commit.author_name);
17 item.set_link(Some(link.clone()));
18- item.set_guid(Some(rss::Guid {
19+ item.set_guid(Some(Guid {
20 permalink: true,
21 value: link,
22 }));
23 @@ -260,6 +260,14 @@ impl Builder {
24 let description = self.templates.render("rss_summary.html", &ctx).unwrap();
25 let mut item = rss::Item::default();
26 item.set_description(Some(description));
27+ item.set_guid(Some(Guid {
28+ value: format!(
29+ "summary-{}-{}",
30+ start.unix_timestamp(),
31+ end.unix_timestamp()
32+ ),
33+ permalink: false,
34+ }));
35 items.push(item);
36 let time_to_live = match timeframe {
37 Timeframe::DAILY => None,
38 @@ -531,6 +539,7 @@ mod tests {
39 .title
40 .as_ref()
41 .is_some_and(|title| title == "Commit: commit 1"));
42+ assert!(channel.items[0].guid.is_some());
43 test_repo.cleanup().expect("failed to cleanup repo");
44 }
45
46 @@ -554,6 +563,7 @@ mod tests {
47 .summary(vec![(path, name)], Timeframe::WEEKLY)
48 .expect("failed to build items");
49 assert!(channel.items.len() == 1);
50+ assert!(channel.items[0].guid.is_some());
51 // check TTL for 3 days
52 assert!(channel.ttl.as_ref().is_some_and(|ttl| ttl == "4320"))
53 }
54 @@ -596,6 +606,7 @@ mod tests {
55 .description
56 .as_ref()
57 .is_some_and(|content| content.contains("commit 1") && content.contains("commit 2")));
58+ assert!(channel.items[0].guid.is_some());
59 // check TTL for 30 days
60 assert!(channel.ttl.as_ref().is_some_and(|ttl| ttl == "21600"))
61 }