Add matrix-hookshot patch for parsing atom feeds with multiple links

This commit is contained in:
Charlotte Van Petegem 2023-06-17 19:05:26 +02:00
parent 836318ff5a
commit 94a55faed7
No known key found for this signature in database
GPG key ID: 019E764B7184435A
2 changed files with 34 additions and 0 deletions

View file

@ -7,6 +7,14 @@
};
config = lib.mkIf config.chvp.services.matrix.enable {
nixpkgs.overlays = [
(self: super: {
matrix-hookshot = super.matrix-hookshot.overrideAttrs (old: {
patches = (old.patches or []) ++ [ ./hookshot-atom-links.patch ];
});
})
];
chvp.base.zfs.systemLinks = [{ path = "/var/lib/matrix-hookshot"; type = "data"; }];
chvp.services.nginx.hosts = [{
fqdn = "matrix.vanpetegem.me";

View file

@ -0,0 +1,26 @@
diff --git a/changelog.d/784.bugfix b/changelog.d/784.bugfix
new file mode 100644
index 0000000..63f29a9
--- /dev/null
+++ b/changelog.d/784.bugfix
@@ -0,0 +1 @@
+Feeds now tries to find an HTML-type link before falling back to the first link when parsing atom feeds
diff --git a/src/feeds/parser.rs b/src/feeds/parser.rs
index c7f59ec..4f1ca71 100644
--- a/src/feeds/parser.rs
+++ b/src/feeds/parser.rs
@@ -81,7 +81,13 @@ fn parse_feed_to_js_result(feed: &Feed) -> JsRssChannel {
.iter()
.map(|item| FeedItem {
title: Some(item.title().value.clone()),
- link: item.links().first().map(|f| f.href.clone()),
+ link: item
+ .links()
+ .iter()
+ .filter(|l| l.mime_type.as_ref().map_or(false, |t| t == "text/html"))
+ .next()
+ .or_else(|| item.links().first())
+ .map(|f| f.href.clone()),
id: Some(item.id.clone()),
// No equivalent
id_is_permalink: false,