8000 [pull] main from miniflux:main by pull[bot] · Pull Request #208 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ func NewConfigOptions() *configOptions {
rawValue: "0",
valueType: boolType,
},
"FILTER_ENTRY_MAX_AGE_DAYS": {
parsedIntValue: 0,
rawValue: "0",
valueType: intType,
validator: func(rawValue string) error {
return validateGreaterOrEqualThan(rawValue, 0)
},
},
"FORCE_REFRESH_INTERVAL": {
parsedDuration: 30 * time.Minute,
rawValue: "30",
Expand Down Expand Up @@ -718,10 +710,6 @@ func (c *configOptions) FetchYouTubeWatchTime() bool {
return c.options["FETCH_YOUTUBE_WATCH_TIME"].parsedBoolValue
}

func (c *configOptions) FilterEntryMaxAgeDays() int {
return c.options["FILTER_ENTRY_MAX_AGE_DAYS"].parsedIntValue
}

func (c *configOptions) ForceRefreshInterval() time.Duration {
return c.options["FORCE_REFRESH_INTERVAL"].parsedDuration
}
Expand Down
16 changes: 0 additions & 16 deletions internal/config/options_parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,22 +1273,6 @@ func TestDatabaseConnectionLifetimeOptionParsing(t *testing.T) {
}
}

func TestFilterEntryMaxAgeDaysOptionParsing(t *testing.T) {
configParser := NewConfigParser()

if configParser.options.FilterEntryMaxAgeDays() != 0 {
t.Fatalf("Expected FILTER_ENTRY_MAX_AGE_DAYS to be 0 by default")
}

if err := configParser.parseLines([]string{"FILTER_ENTRY_MAX_AGE_DAYS=7"}); err != nil {
t.Fatalf("Unexpected error: %v", err)
}

if configParser.options.FilterEntryMaxAgeDays() != 7 {
t.Fatalf("Expected FILTER_ENTRY_MAX_AGE_DAYS to be 7 days")
}
}

func TestForceRefreshIntervalOptionParsing(t *testing.T) {
configParser := NewConfigParser()

Expand Down
4 changes: 4 additions & 0 deletions internal/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"net/url"
"os"
"strconv"
Expand Down Expand Up @@ -119,6 +120,9 @@ func (cp *configParser) parseLines(lines []string) error {
func (cp *configParser) parseLine(key, value string) error {
field, exists := cp.options.options[key]
if !exists {
if key == "FILTER_ENTRY_MAX_AGE_DAYS" {
slog.Warn("Configuration option FILTER_ENTRY_MAX_AGE_DAYS is deprecated; use user filter rule max-age:<duration> instead")
}
// Ignore unknown configuration keys to avoid parsing unrelated environment variables.
return nil
}
Expand Down
25 changes: 0 additions & 25 deletions internal/reader/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"strings"
"time"

"miniflux.app/v2/internal/config"
"miniflux.app/v2/internal/model"
)

Expand Down Expand Up @@ -70,10 +69,6 @@ func parseRule(userDefinedRule string) (bool, filterRule) {
}

func IsBlockedEntry(blockRules filterRules, allowRules filterRules, feed *model.Feed, entry *model.Entry) bool {
if isBlockedGlobally(entry) {
return true
}

if matchesEntryFilterRules(blockRules, feed, entry) {
return true
}
Expand Down Expand Up @@ -101,26 +96,6 @@ func IsBlockedEntry(blockRules filterRules, allowRules filterRules, feed *model.
return false
}

func isBlockedGlobally(entry *model.Entry) bool {
if config.Opts == nil {
return false
}

if config.Opts.FilterEntryMaxAgeDays() > 0 {
maxAge := time.Duration(config.Opts.FilterEntryMaxAgeDays()) * 24 * time.Hour
if entry.Date.Before(time.Now().Add(-maxAge)) {
slog.Debug("Entry is blocked globally due to max age",
slog.String("entry_url", entry.URL),
slog.Time("entry_date", entry.Date),
slog.Duration("max_age", maxAge),
)
return true
}
}

return false
}

// matchesEntryRegexRules checks if the entry matches the regex rules defined in the feed or user settings.
// It returns true if the entry matches the regex pattern, and a boolean indicating if the regex is valid.
func matchesEntryRegexRules(regexPattern string, feed *model.Feed, entry *model.Entry) (bool, bool) {
Expand Down
35 changes: 0 additions & 35 deletions internal/reader/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
package filter // import "miniflux.app/v2/internal/reader/filter"

import (
"os"
"testing"
"time"

"miniflux.app/v2/internal/config"
"miniflux.app/v2/internal/model"
)

Expand Down Expand Up @@ -411,39 +409,6 @@ func TestKeeplistRulesBehavior(t *testing.T) {
}
}

// Tests for isBlockedGlobally function
func TestIsBlockedGlobally(t *testing.T) {
var err error
config.Opts, err = config.NewConfigParser().ParseEnvironmentVariables()
if err != nil {
t.Fatalf(`Parsing failure: %v`, err)
}

testEntry := createTestEntry()
testEntry.Date = time.Date(2020, 5, 1, 05, 05, 05, 05, time.UTC)

if IsBlockedEntry(nil, nil, createTestFeed(), testEntry) {
t.Error("Expected no entries to be blocked globally when max-age is not set")
}

os.Setenv("FILTER_ENTRY_MAX_AGE_DAYS", "30")
defer os.Clearenv()

config.Opts, err = config.NewConfigParser().ParseEnvironmentVariables()
if err != nil {
t.Fatalf(`Parsing failure: %v`, err)
}

if !IsBlockedEntry(nil, nil, createTestFeed(), testEntry) {
t.Error("Expected entries to be blocked globally when max-age is set")
}

testEntry.Date = time.Now().Add(-2 * 24 * time.Hour)
if isBlockedGlobally(testEntry) {
t.Error("Expected entries not to be blocked globally when they are within the max-age limit")
}
}

// Tests for matchesEntryRegexRules function
func TestMatchesEntryRegexRules(t *testing.T) {
entry := createTestEntry()
Expand Down
7 changes: 0 additions & 7 deletions miniflux.1
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ use it as a reading time\&.
.br
Disabled by default\&.
.TP
.B FILTER_ENTRY_MAX_AGE_DAYS
Ignore new entries older than the given number of days\&.
.br
Set to 7 to fetch only entries from the last 7 days\&.
.br
Default is 0 (disabled)\&.
.TP
.B FORCE_REFRESH_INTERVAL
The minimum interval for manual refresh\&.
.br
Expand Down
Loading
0