Feed the full content flag to reduce web requests

This commit is contained in:
LittleSheep 2025-04-06 13:27:57 +08:00
parent fd0d3699e4
commit fd9761f328
2 changed files with 13 additions and 6 deletions

View File

@ -12,7 +12,8 @@ type SubscriptionFeed struct {
cruda.BaseModel
URL string `json:"url"`
IsEnabled bool `json:"enabled"`
IsEnabled bool `json:"is_enabled"`
IsFullContent bool `json:"is_full_content"`
PullInterval int `json:"pull_interval"`
Adapter string `json:"adapter"`
AccountID *uint `json:"account_id"`

View File

@ -183,12 +183,18 @@ func feedReadGuidedFeed(src models.SubscriptionFeed, eager ...bool) ([]models.Su
parent.Thumbnail = item.Image.URL
}
article, err := ScrapSubscriptionItem(item.Link, parent)
if err != nil {
log.Warn().Err(err).Str("url", item.Link).Msg("Failed to scrap a news article...")
continue
// When the source enabled the full content,
// It means the feed contains all the content, and we're not going to scrap it
if src.IsFullContent {
result = append(result, pgConvert(parent))
} else {
article, err := ScrapSubscriptionItem(item.Link, parent)
if err != nil {
log.Warn().Err(err).Str("url", item.Link).Msg("Failed to scrap a news article...")
continue
}
result = append(result, pgConvert(*article))
}
result = append(result, pgConvert(*article))
log.Debug().Str("url", item.Link).Msg("Scraped a news article...")
}