This commit delivers the core logic for the Multi-Digest Architecture. Phase 2 (Filter Engine): - Implemented 'internal/filter' with exact/prefix/regex matching. - Implemented 'internal/manager' for digest priority assignment. - Updated 'models.Entry' to include 'SiteURL'. Phase 3 (Processor Refactor): - Updated 'ProcessDigest' to filter entries using 'DigestManager'. - Updated 'main.go' to schedule jobs per digest index. Phase 4 (LLM & Categorization): - Added 'DefaultCategories' in 'internal/config'. - Updated LLM prompts and service flow to respect user-defined or default categories. - Updated mocks and tests across the board. The application now supports configuring multiple digests with distinct filters and categories, and correctly assigns entries and prompts the LLM accordingly.
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"miniflux-digest/internal/models"
|
|
miniflux "miniflux.app/v2/client"
|
|
)
|
|
|
|
type MinifluxClientWrapper struct {
|
|
client *miniflux.Client
|
|
}
|
|
|
|
func NewMinifluxClientWrapper(client *miniflux.Client) *MinifluxClientWrapper {
|
|
return &MinifluxClientWrapper{client: client}
|
|
}
|
|
|
|
func (m *MinifluxClientWrapper) FeedIcon(feedID int64) (*models.FeedIcon, error) {
|
|
icon, err := m.client.FeedIcon(feedID)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &models.FeedIcon{
|
|
FeedID: feedID,
|
|
Data: icon.Data,
|
|
}, nil
|
|
}
|
|
|
|
func (m *MinifluxClientWrapper) GetAllUnreadEntries() ([]*models.Entry, error) {
|
|
minifluxEntries, err := m.client.Entries(&miniflux.Filter{Status: miniflux.EntryStatusUnread})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var entries []*models.Entry
|
|
for _, entry := range minifluxEntries.Entries {
|
|
var categoryID int64
|
|
var categoryTitle string
|
|
if entry.Feed != nil && entry.Feed.Category != nil {
|
|
categoryID = entry.Feed.Category.ID
|
|
categoryTitle = entry.Feed.Category.Title
|
|
}
|
|
var feedTitle string
|
|
var siteURL string
|
|
if entry.Feed != nil {
|
|
feedTitle = entry.Feed.Title
|
|
siteURL = entry.Feed.SiteURL
|
|
}
|
|
|
|
entries = append(entries, &models.Entry{
|
|
ID: entry.ID,
|
|
Title: entry.Title,
|
|
URL: entry.URL,
|
|
SiteURL: siteURL,
|
|
Content: entry.Content,
|
|
FeedID: entry.FeedID,
|
|
FeedTitle: feedTitle,
|
|
GroupID: categoryID,
|
|
GroupTitle: categoryTitle,
|
|
CommentsURL: entry.CommentsURL,
|
|
Date: entry.Date,
|
|
})
|
|
}
|
|
return entries, nil
|
|
}
|
|
|
|
func (m *MinifluxClientWrapper) UpdateEntries(entryIDs []int64, status string) error {
|
|
return m.client.UpdateEntries(entryIDs, status)
|
|
}
|