Add category to RSS feeds (fixes #3446) (#5030)

This commit is contained in:
Nutomic 2024-09-19 15:43:58 +02:00 committed by Felix Ableitner
parent 76728776fd
commit 6840a5e367

View file

@ -27,6 +27,7 @@ use lemmy_utils::{
}; };
use rss::{ use rss::{
extension::{dublincore::DublinCoreExtension, ExtensionBuilder, ExtensionMap}, extension::{dublincore::DublinCoreExtension, ExtensionBuilder, ExtensionMap},
Category,
Channel, Channel,
EnclosureBuilder, EnclosureBuilder,
Guid, Guid,
@ -569,6 +570,10 @@ fn create_post_items(posts: Vec<PostView>, protocol_and_hostname: &str) -> Lemmy
BTreeMap::from([("content".to_string(), vec![thumbnail_ext.build()])]), BTreeMap::from([("content".to_string(), vec![thumbnail_ext.build()])]),
); );
} }
let category = Category {
name: p.community.title,
domain: Some(p.community.actor_id.to_string()),
};
let i = Item { let i = Item {
title: Some(sanitize_html(sanitize_xml(p.post.name).as_str())), title: Some(sanitize_html(sanitize_xml(p.post.name).as_str())),
@ -580,6 +585,7 @@ fn create_post_items(posts: Vec<PostView>, protocol_and_hostname: &str) -> Lemmy
link: Some(post_url.clone()), link: Some(post_url.clone()),
extensions, extensions,
enclosure: enclosure_opt, enclosure: enclosure_opt,
categories: vec![category],
..Default::default() ..Default::default()
}; };