-
Notifications
You must be signed in to change notification settings - Fork 188
Added feature to drop article if title matches a regex provided by the user #3527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a new feature allowing users to filter out articles from their RSS feeds based on a regex pattern matching the article title. Users can configure the regex pattern through a new input field in the app settings.
Changes:
- Added frontend state management for
titleFilterRegexsetting in the Vuex store - Added a text input field in the app settings dialog for users to enter the regex pattern
- Implemented backend filtering logic that skips articles matching the regex during feed fetching
- Registered the new setting in the PageController to load the initial state
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| src/store/app.ts | Adds titleFilterRegex to app state, getters, and mutations for storing the regex pattern |
| src/components/modals/AppSettingsDialog.vue | Adds NcTextField component for users to input the regex pattern in settings |
| lib/Service/FeedServiceV2.php | Implements article filtering logic using the regex pattern during feed fetch operations |
| lib/Controller/PageController.php | Registers titleFilterRegex setting to be loaded on page initialization |
Comments suppressed due to low confidence (1)
lib/Service/FeedServiceV2.php:425
- Logical bug: The unread count calculation will be incorrect when articles are filtered out. The code at lines 415-423 counts unread items from the
$itemsarray, but filtered items (skipped viacontinueat line 395) are still present in this array - they're just not inserted into the database. This means the unread count will include filtered items that don't actually exist in the database.
To fix this, either:
- Remove filtered items from the
$itemsarray instead of usingcontinue, or - Calculate the unread count only from successfully inserted items, or
- Track inserted items in a separate array and count from that
foreach (array_reverse($items) as &$item) {
$filterBy = $this->userConfig->getValueString( $feed->getUserId(), 'news', 'titleFilterRegex');
if( $item->getTitle() !== null && !empty($filterBy ) && preg_match( $filterBy, $item->getTitle() ) ) {
$this->logger->trace( 'Item filtered: {title}', [ 'title' => $item->getTitle() ] );
continue;
}
$item->setFeedId($feed->getId())
->setBody($this->purifier->purify($item->getBody()));
// update modes: 0 nothing, 1 set unread
if ($feed->getUpdateMode() === Feed::UPDATE_MODE_NORMAL) {
$item->setUnread(true);
}
$item = $this->itemService->insertOrUpdate($item);
}
// mark feed as successfully updated
$feed->setUpdateErrorCount(0);
$feed->setLastUpdateError(null);
$unreadCount = 0;
array_map(
function (Item $item) use (&$unreadCount): void {
if ($item->isUnread()) {
$unreadCount++;
}
},
$items
);
return $this->mapper->update($feed)->setUnreadCount($unreadCount);
…e user Signed-off-by: Markus87 <[email protected]>
…rConfig in FeedServiceTest.php Signed-off-by: Markus87 <[email protected]>
a31a74d to
33bf955
Compare
Summary
This adds a input field in the settings of the app which allows the user to drop articles if their title matches the regex.
I am aware some of this checklist may not be perfect yet, but I doubt the changes will make it anyway like this.
It would be cool if somebody who actually understands this app better than me to have a look if this is permissible at all.
Checklist