Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Dec 20, 2024
1 parent e24f457 commit 483c41d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/librssguard/core/feeddownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
<< " microseconds.";

QList<Message> read_msgs, important_msgs;
QHash<int, bool> loaded_filters;

for (int i = 0; i < msgs.size(); i++) {
Message msg_original(msgs[i]);
Expand Down Expand Up @@ -296,10 +295,7 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
tmr.restart();

try {
MessageObject::FilteringAction decision =
msg_filter->filterMessage(&filter_engine, !loaded_filters.contains(msg_filter->id()));

loaded_filters.insert(msg_filter->id(), true);
MessageObject::FilteringAction decision = msg_filter->filterMessage(&filter_engine);

qDebugNN << LOGSEC_FEEDDOWNLOADER << "Running filter script, it took " << tmr.nsecsElapsed() / 1000
<< " microseconds.";
Expand Down
22 changes: 9 additions & 13 deletions src/librssguard/core/messagefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@

MessageFilter::MessageFilter(int id, QObject* parent) : QObject(parent), m_id(id) {}

MessageObject::FilteringAction MessageFilter::filterMessage(QJSEngine* engine, bool evaluate_filter) {
if (evaluate_filter) {
QJSValue filter_func =
engine->evaluate(qApp->replaceUserDataFolderPlaceholder(m_script).replace(QSL("filterMessage()"),
QSL("filterMessage%1()").arg(m_id)));

if (filter_func.isError()) {
QJSValue::ErrorType error = filter_func.errorType();
QString message = filter_func.toString();

throw FilteringException(error, message);
}
MessageObject::FilteringAction MessageFilter::filterMessage(QJSEngine* engine) {
QJSValue filter_func = engine->evaluate(qApp->replaceUserDataFolderPlaceholder(m_script));

if (filter_func.isError()) {
QJSValue::ErrorType error = filter_func.errorType();
QString message = filter_func.toString();

throw FilteringException(error, message);
}

auto filter_output = engine->evaluate(QSL("filterMessage%1()").arg(m_id));
auto filter_output = engine->evaluate(QSL("filterMessage()"));

if (filter_output.isError()) {
QJSValue::ErrorType error = filter_output.errorType();
Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/core/messagefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RSSGUARD_DLLSPEC MessageFilter : public QObject {
public:
explicit MessageFilter(int id = -1, QObject* parent = nullptr);

MessageObject::FilteringAction filterMessage(QJSEngine* engine, bool evaluate_filter = true);
MessageObject::FilteringAction filterMessage(QJSEngine* engine);

int id() const;
void setId(int id);
Expand Down

0 comments on commit 483c41d

Please sign in to comment.