From a1a81e073e7c6e12195ed88874aee01150cc26d6 Mon Sep 17 00:00:00 2001 From: Silas Schöffel Date: Sun, 29 Dec 2024 22:39:08 +0100 Subject: feat(pkgs/back): add comments to rss feed --- pkgs/by-name/ba/back/src/web/mod.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ba/back/src/web/mod.rs b/pkgs/by-name/ba/back/src/web/mod.rs index 968c827..f7a4077 100644 --- a/pkgs/by-name/ba/back/src/web/mod.rs +++ b/pkgs/by-name/ba/back/src/web/mod.rs @@ -110,7 +110,8 @@ pub fn closed(config: &State) -> error::Result> { pub fn feed(config: &State) -> error::Result> { use rss::{ChannelBuilder, Item, ItemBuilder}; - let items: Vec = issues_from_repository(&config.repository.to_thread_local())? + //Collect all Items as rss items + let mut items: Vec = issues_from_repository(&config.repository.to_thread_local())? .into_iter() .map(|issue| issue.collapse()) .map(|issue| { @@ -123,6 +124,30 @@ pub fn feed(config: &State) -> error::Result> { .build() }) .collect(); + //Append all comments after converting them to rss items + items.extend( + issues_from_repository(&config.repository.to_thread_local())? + .into_iter() + .map(|issue| issue.collapse()) + .filter(|issue| issue.comments.len() > 0) + .map(|issue| { + issue + .comments + .into_iter() + .map(|comment| { + ItemBuilder::default() + .title(issue.title.to_string()) + .author(comment.author.to_string()) + .description(comment.message.to_string()) + .pub_date(comment.timestamp.to_string()) + .link(format!("{}/issue/{}", &config.root.to_string(), issue.id)) + .build() + }) + .collect::>() + }) + .flatten() + .collect::>(), + ); let channel = ChannelBuilder::default() .title("Issues") -- cgit 1.4.1