From baab73d521131a857ab6488bd2b40201f81f7bc8 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 20 Dec 2023 07:08:53 +0100 Subject: [PATCH] fix: Include type for OPML subscriptions As per [OPML 2.0 specification]: > Each sub-element of the body of the OPML document is a node of type rss or an outline element that contains nodes of type rss. > Required attributes: type, text, xmlUrl. [OPML 2.0 specification]: http://opml.org/spec2.opml#subscriptionLists --- internal/reader/opml/opml.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/reader/opml/opml.go b/internal/reader/opml/opml.go index 2f7147a0335..05aefd6453a 100644 --- a/internal/reader/opml/opml.go +++ b/internal/reader/opml/opml.go @@ -34,6 +34,23 @@ type opmlOutline struct { Outlines opmlOutlineCollection `xml:"outline,omitempty"` } +func (outline opmlOutline) MarshalXML() ([]byte, error) { + type opmlOutlineXml opmlOutline + + outlineType := "" + if IsSubscription(outline) { + outlineType = "rss" + } + + return xml.Marshal(struct { + opmlOutlineXml + Type string `xml:"type,attr,omitempty"` + }{ + opmlOutlineXml: opmlOutlineXml(outline), + Type: outlineType, + }) +} + func (o *opmlOutline) IsSubscription() bool { return strings.TrimSpace(o.FeedURL) != "" }