From 0bf55868818a6d8d58534915f6d52ec3c299a5f0 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Wed, 8 May 2019 15:03:43 -0700 Subject: [PATCH] Use feed's title if item does not have one This prevents a link from not being shown if an item's title could not be extracted. Workaround(?) fix for matrix-org#284. --- src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 32495c5..d3622e5 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -349,6 +349,11 @@ func (s *Service) sendToRooms(cli *gomatrix.Client, feedURL string, feed *gofeed } func itemToHTML(feed *gofeed.Feed, item gofeed.Item) gomatrix.HTMLMessage { + // If an item does not have a title, try using the feed's title instead + if item.Title == "" { + item.Title = feed.Title + } + return gomatrix.HTMLMessage{ Body: fmt.Sprintf("%s: %s (%s)", html.EscapeString(feed.Title), html.EscapeString(item.Title), html.EscapeString(item.Link)),