2026-08-05 12:06:46 +05:00
|
|
|
package fixers
|
|
|
|
|
|
2026-08-09 07:27:19 +05:00
|
|
|
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{
|
2026-08-09 07:27:19 +05:00
|
|
|
"github.com": githubFixer,
|
2026-08-05 12:06:46 +05:00
|
|
|
"www.opennet.ru": opennetFixer,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fix fixes title and body depending on site parsed.
|
2026-08-09 07:27:19 +05:00
|
|
|
func Fix(domain string, feedItem *gofeed.Item) (string, string) {
|
2026-08-05 12:06:46 +05:00
|
|
|
fixer, found := fixers[domain]
|
2026-08-09 07:46:06 +05:00
|
|
|
if found {
|
|
|
|
|
return fixer(feedItem)
|
2026-08-05 12:06:46 +05:00
|
|
|
}
|
|
|
|
|
|
2026-08-09 07:46:06 +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
|
|
|
}
|