diff options
author | Silas Schöffel <sils@sils.li> | 2024-12-29 22:39:08 +0100 |
---|---|---|
committer | Silas Schöffel <sils@sils.li> | 2024-12-31 01:35:55 +0100 |
commit | a1a81e073e7c6e12195ed88874aee01150cc26d6 (patch) | |
tree | 811bd69baafd97210aea1a8ffbd30100977444a9 | |
parent | fix(pkgs/back/contrib/config.json): add root_url (diff) | |
download | nixos-server-rssback.zip |
feat(pkgs/back): add comments to rss feed rssback
-rw-r--r-- | pkgs/by-name/ba/back/src/web/mod.rs | 27 |
1 files changed, 26 insertions, 1 deletions
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<BackConfig>) -> error::Result<RawHtml<String>> { pub fn feed(config: &State<BackConfig>) -> error::Result<RawHtml<String>> { use rss::{ChannelBuilder, Item, ItemBuilder}; - let items: Vec<Item> = issues_from_repository(&config.repository.to_thread_local())? + //Collect all Items as rss items + let mut items: Vec<Item> = 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<BackConfig>) -> error::Result<RawHtml<String>> { .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::<Vec<Item>>() + }) + .flatten() + .collect::<Vec<Item>>(), + ); let channel = ChannelBuilder::default() .title("Issues") |