Files

27 lines
629 B
Go
Raw Permalink Normal View History

2026-08-05 12:06:46 +05:00
package fixers
import "github.com/mmcdole/gofeed"
type fixerFunc func(feedItem *gofeed.Item) (string, string)
2026-08-05 12:06:46 +05:00
var fixers = map[string]fixerFunc{
"github.com": githubFixer,
2026-08-05 12:06:46 +05:00
"www.opennet.ru": opennetFixer,
}
// Fix fixes title and body depending on site parsed.
func Fix(domain string, feedItem *gofeed.Item) (string, string) {
2026-08-05 12:06:46 +05:00
fixer, found := fixers[domain]
if found {
return fixer(feedItem)
2026-08-05 12:06:46 +05:00
}
// We should check WHAT IS LONGER - description or content.
bodyData := feedItem.Description
if len(feedItem.Content) > len(feedItem.Description) {
bodyData = feedItem.Content
}
return feedItem.Title, bodyData
2026-08-05 12:06:46 +05:00
}