From b42f328e1459cdead8734579f26924c1f02ba7a6 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 13 Nov 2020 09:14:15 +0100 Subject: [PATCH] Update docs, some comments. --- resources/docs/Message-filters.md | 13 ++++++++++++ .../miscellaneous/databasequeries.cpp | 21 +++++++++++-------- .../services/standard/standardfeed.cpp | 1 - 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/resources/docs/Message-filters.md b/resources/docs/Message-filters.md index 55936fc79..78f7192a7 100755 --- a/resources/docs/Message-filters.md +++ b/resources/docs/Message-filters.md @@ -48,6 +48,19 @@ function filterMessage() { return MSG_ACCEPT; } ``` + +Make sure that your receive only one message with particular URL and all other messages with same URL are subsequently ignored. +```js +function filterMessage() { + if (msg.isDuplicateWithAttribute(2)) { + return MSG_IGNORE; + } + else { + return MSG_ACCEPT; + } +} +``` + ## `Message filters` dialog The dialog is accessible from menu `Messages -> Message filters` and is the central place for message filters management within RSS Guard. It allows you to: * add or remove message filters, diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index 3e8d23d0e..69078b6c5 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -888,9 +888,9 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, } int id_existing_message = -1; - qint64 date_existing_message; - bool is_read_existing_message; - bool is_important_existing_message; + qint64 date_existing_message = 0; + bool is_read_existing_message = false; + bool is_important_existing_message = false; QString contents_existing_message; QString feed_id_existing_message; @@ -973,19 +973,22 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, // Message is already in the DB. // // Now, we update it if at least one of next conditions is true: - // 1) Message has custom ID AND (its date OR read status OR starred status are changed). + // 1) Message has custom ID AND (its date OR read status OR starred status are changed or message + // was moved from one feed to another - this can particularly happen in Gmail feeds). + // // 2) Message has its date fetched from feed AND its date is different from date in DB and contents is changed. if (/* 1 */ (!message.m_customId.isEmpty() && (message.m_created.toMSecsSinceEpoch() != date_existing_message || message.m_isRead != is_read_existing_message || message.m_isImportant != is_important_existing_message || - message.m_feedId != feed_id_existing_message)) || + message.m_feedId != feed_id_existing_message || + message.m_contents != contents_existing_message)) || /* 2 */ (message.m_createdFromFeed && message.m_created.toMSecsSinceEpoch() != date_existing_message && message.m_contents != contents_existing_message)) { // Message exists, it is changed, update it. query_update.bindValue(QSL(":title"), unnulifyString(message.m_title)); - query_update.bindValue(QSL(":is_read"), (int) message.m_isRead); - query_update.bindValue(QSL(":is_important"), (int) message.m_isImportant); + query_update.bindValue(QSL(":is_read"), int(message.m_isRead)); + query_update.bindValue(QSL(":is_important"), int(message.m_isImportant)); query_update.bindValue(QSL(":url"), unnulifyString(message.m_url)); query_update.bindValue(QSL(":author"), unnulifyString(message.m_author)); query_update.bindValue(QSL(":date_created"), message.m_created.toMSecsSinceEpoch()); @@ -1019,8 +1022,8 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, // Message with this URL is not fetched in this feed yet. query_insert.bindValue(QSL(":feed"), unnulifyString(feed_custom_id)); query_insert.bindValue(QSL(":title"), unnulifyString(message.m_title)); - query_insert.bindValue(QSL(":is_read"), (int) message.m_isRead); - query_insert.bindValue(QSL(":is_important"), (int) message.m_isImportant); + query_insert.bindValue(QSL(":is_read"), int(message.m_isRead)); + query_insert.bindValue(QSL(":is_important"), int(message.m_isImportant)); query_insert.bindValue(QSL(":url"), unnulifyString( message.m_url)); query_insert.bindValue(QSL(":author"), unnulifyString(message.m_author)); query_insert.bindValue(QSL(":date_created"), message.m_created.toMSecsSinceEpoch()); diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp index 432d38f81..9b9aaa99c 100644 --- a/src/librssguard/services/standard/standardfeed.cpp +++ b/src/librssguard/services/standard/standardfeed.cpp @@ -435,7 +435,6 @@ QList StandardFeed::obtainNewMessages(bool* error_during_obtaining) { QList> headers; headers << NetworkFactory::generateBasicAuthHeader(username(), password()); - m_networkError = NetworkFactory::performNetworkOperation(url(), download_timeout, QByteArray(),