summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/config.php2
-rwxr-xr-xclasses/pref/filters.php28
-rwxr-xr-xclasses/rssutils.php28
-rw-r--r--js/CommonFilters.js3
-rw-r--r--sql/mysql/migrations/146.sql2
-rw-r--r--sql/mysql/schema.sql3
-rw-r--r--sql/pgsql/migrations/146.sql2
-rw-r--r--sql/pgsql/schema.sql3
8 files changed, 46 insertions, 25 deletions
diff --git a/classes/config.php b/classes/config.php
index 1c65fc76f..2c78b908d 100644
--- a/classes/config.php
+++ b/classes/config.php
@@ -6,7 +6,7 @@ class Config {
const T_STRING = 2;
const T_INT = 3;
- const SCHEMA_VERSION = 145;
+ const SCHEMA_VERSION = 146;
/** override default values, defined below in _DEFAULTS[], prefixing with _ENVVAR_PREFIX:
*
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index 6e6e3d9ee..04178f1a6 100755
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -1,6 +1,15 @@
<?php
class Pref_Filters extends Handler_Protected {
+ const ACTION_TAG = 4;
+ const ACTION_SCORE = 6;
+ const ACTION_LABEL = 7;
+ const ACTION_PLUGIN = 9;
+ const ACTION_REMOVE_TAG = 10;
+
+ const PARAM_ACTIONS = [self::ACTION_TAG, self::ACTION_SCORE,
+ self::ACTION_LABEL, self::ACTION_PLUGIN, self::ACTION_REMOVE_TAG];
+
function csrf_ignore(string $method): bool {
$csrf_ignored = array("index", "getfiltertree", "savefilterorder");
@@ -274,7 +283,7 @@ class Pref_Filters extends Handler_Protected {
}
}
- if ($line['action_id'] == 7) {
+ if ($line['action_id'] == self::ACTION_LABEL) {
$label_sth = $this->pdo->prepare("SELECT fg_color, bg_color
FROM ttrss_labels2 WHERE caption = ? AND
owner_uid = ?");
@@ -474,11 +483,7 @@ class Pref_Filters extends Handler_Protected {
$title = __($row["description"]);
- if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
- $action["action_id"] == 7)
- $title .= ": " . $action["action_param"];
-
- if ($action["action_id"] == 9) {
+ if ($action["action_id"] == self::ACTION_PLUGIN) {
list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
$filter_actions = PluginHost::getInstance()->get_filter_actions();
@@ -491,6 +496,8 @@ class Pref_Filters extends Handler_Protected {
}
}
}
+ } else if (in_array($action["action_id"], self::PARAM_ACTIONS)) {
+ $title .= ": " . $action["action_param"];
}
}
@@ -596,14 +603,19 @@ class Pref_Filters extends Handler_Protected {
$action_param = $action["action_param"];
$action_param_label = $action["action_param_label"];
- if ($action_id == 7) {
+ if ($action_id == self::ACTION_LABEL) {
$action_param = $action_param_label;
}
- if ($action_id == 6) {
+ if ($action_id == self::ACTION_SCORE) {
$action_param = (int)str_replace("+", "", $action_param);
}
+ if (in_array($action_id, [self::ACTION_TAG, self::ACTION_REMOVE_TAG])) {
+ $action_param = implode(", ", FeedItem_Common::normalize_categories(
+ explode(",", $action_param)));
+ }
+
$asth->execute([$filter_id, $action_id, $action_param]);
}
}
diff --git a/classes/rssutils.php b/classes/rssutils.php
index b886a060c..7b50343f6 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -1164,32 +1164,30 @@ class RSSUtils {
}
// check for manual tags (we have to do it here since they're loaded from filters)
-
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
+ $entry_tags = array_merge($entry_tags,
+ FeedItem_Common::normalize_categories(explode(",", $f["param"])));
+ }
+ }
- $manual_tags = array_map('trim', explode(",", mb_strtolower($f["param"])));
-
- foreach ($manual_tags as $tag) {
- array_push($entry_tags, $tag);
- }
+ // like boring tags, but filter-based
+ foreach ($article_filters as $f) {
+ if ($f["type"] == "ignore-tag") {
+ $entry_tags = array_diff($entry_tags,
+ FeedItem_Common::normalize_categories(explode(",", $f["param"])));
}
}
// Skip boring tags
-
- $boring_tags = array_map('trim',
- explode(",", mb_strtolower(
- get_pref(Prefs::BLACKLISTED_TAGS, $feed_obj->owner_uid))));
-
$entry_tags = FeedItem_Common::normalize_categories(
- array_unique(
- array_diff($entry_tags, $boring_tags)));
+ array_diff($entry_tags,
+ FeedItem_Common::normalize_categories(explode(",",
+ get_pref(Prefs::BLACKLISTED_TAGS, $feed_obj->owner_uid)))));
- Debug::log("filtered tags: " . implode(", ", $entry_tags), Debug::LOG_VERBOSE);
+ Debug::log("resulting article tags: " . implode(", ", $entry_tags), Debug::LOG_VERBOSE);
// Save article tags in the database
-
if (count($entry_tags) > 0) {
$tsth = $pdo->prepare("SELECT id FROM ttrss_tags
diff --git a/js/CommonFilters.js b/js/CommonFilters.js
index 8a20480f0..434ee72c7 100644
--- a/js/CommonFilters.js
+++ b/js/CommonFilters.js
@@ -16,7 +16,8 @@ const Filters = {
ACTION_SCORE: 6,
ACTION_LABEL: 7,
ACTION_PLUGIN: 9,
- PARAM_ACTIONS: [4, 6, 7, 9],
+ ACTION_REMOVE_TAG: 10,
+ PARAM_ACTIONS: [4, 6, 7, 9, 10],
filter_info: {},
test: function() {
const test_dialog = new fox.SingleUseDialog({
diff --git a/sql/mysql/migrations/146.sql b/sql/mysql/migrations/146.sql
new file mode 100644
index 000000000..6d4824727
--- /dev/null
+++ b/sql/mysql/migrations/146.sql
@@ -0,0 +1,2 @@
+insert into ttrss_filter_actions (id,name,description) values (10, 'ignore-tag',
+ 'Ignore tags');
diff --git a/sql/mysql/schema.sql b/sql/mysql/schema.sql
index ff6ff4797..589d1013a 100644
--- a/sql/mysql/schema.sql
+++ b/sql/mysql/schema.sql
@@ -249,6 +249,9 @@ insert into ttrss_filter_actions (id,name,description) values (8, 'stop',
insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
'Invoke plugin');
+insert into ttrss_filter_actions (id,name,description) values (10, 'ignore-tag',
+ 'Ignore tags');
+
create table ttrss_filters2(id integer primary key auto_increment,
owner_uid integer not null,
match_any_rule boolean not null default false,
diff --git a/sql/pgsql/migrations/146.sql b/sql/pgsql/migrations/146.sql
new file mode 100644
index 000000000..6d4824727
--- /dev/null
+++ b/sql/pgsql/migrations/146.sql
@@ -0,0 +1,2 @@
+insert into ttrss_filter_actions (id,name,description) values (10, 'ignore-tag',
+ 'Ignore tags');
diff --git a/sql/pgsql/schema.sql b/sql/pgsql/schema.sql
index b539419b6..938ccc905 100644
--- a/sql/pgsql/schema.sql
+++ b/sql/pgsql/schema.sql
@@ -245,6 +245,9 @@ insert into ttrss_filter_actions (id,name,description) values (8, 'stop',
insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
'Invoke plugin');
+insert into ttrss_filter_actions (id,name,description) values (10, 'ignore-tag',
+ 'Ignore tags');
+
create table ttrss_filters2(id serial not null primary key,
owner_uid integer not null references ttrss_users(id) on delete cascade,
match_any_rule boolean not null default false,