Browse Source
Merge pull request #285 from matrix-org/anoadragon453-patch-1
Use feed's title if item does not have one
pull/276/merge
Kegsay
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
8 additions and
1 deletions
-
src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go
|
|
@ -349,13 +349,20 @@ 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
|
|
|
|
// Create a new variable instead of mutating that which is passed in
|
|
|
|
itemTitle := item.Title |
|
|
|
if itemTitle == "" { |
|
|
|
itemTitle = feed.Title |
|
|
|
} |
|
|
|
|
|
|
|
return gomatrix.HTMLMessage{ |
|
|
|
Body: fmt.Sprintf("%s: %s ( %s )", |
|
|
|
html.EscapeString(feed.Title), html.EscapeString(item.Title), html.EscapeString(item.Link)), |
|
|
|
MsgType: "m.notice", |
|
|
|
Format: "org.matrix.custom.html", |
|
|
|
FormattedBody: fmt.Sprintf("<strong>%s</strong>:<br><a href=\"%s\"><strong>%s</strong></a>", |
|
|
|
html.EscapeString(feed.Title), html.EscapeString(item.Link), html.EscapeString(item.Title)), |
|
|
|
html.EscapeString(feed.Title), html.EscapeString(item.Link), html.EscapeString(itemTitle)), |
|
|
|
// <strong>FeedTitle</strong>:
|
|
|
|
// <br>
|
|
|
|
// <a href="url-of-the-entry"><strong>Title of the Entry</strong></a>
|
|
|
|