diff --git a/resources/docs/Documentation.md b/resources/docs/Documentation.md index 885d03b1d..efc483f5b 100644 --- a/resources/docs/Documentation.md +++ b/resources/docs/Documentation.md @@ -158,6 +158,7 @@ Note that `MessageObject` attributes which can be synchronized back to service a | `SameAuthor` | 4 | Check if message has same author as some another messages. | | `SameDateCreated` | 8 | Check if message has same date of creation as some another messages. | | `AllFeedsSameAccount` | 16 | Perform the check across all feeds from your account, not just "current" feed. | +| `SameCustomId` | 32 | Check if message with same custom ID exists in RSS Guard's DB. | #### `utils` object | Method | How to call | Description | diff --git a/src/librssguard/core/messageobject.cpp b/src/librssguard/core/messageobject.cpp index fa9819b09..0d81d578f 100644 --- a/src/librssguard/core/messageobject.cpp +++ b/src/librssguard/core/messageobject.cpp @@ -44,6 +44,11 @@ bool MessageObject::isDuplicateWithAttribute(MessageObject::DuplicationAttribute bind_values.append({ QSL(":date_created"), created().toMSecsSinceEpoch() }); } + if ((attribute_check& DuplicationAttributeCheck::SameCustomId) == DuplicationAttributeCheck::SameCustomId) { + where_clauses.append(QSL("custom_id = :custom_id")); + bind_values.append({ QSL(":custom_id"), customId() }); + } + where_clauses.append(QSL("account_id = :account_id")); bind_values.append({ QSL(":account_id"), accountId() }); @@ -219,6 +224,14 @@ int MessageObject::accountId() const { return m_accountId; } +QString MessageObject::customId() const { + return m_message->m_customId; +} + +int MessageObject::id() const { + return m_message->m_id; +} + QList MessageObject::assignedLabels() const { return m_message->m_assignedLabels; } diff --git a/src/librssguard/core/messageobject.h b/src/librssguard/core/messageobject.h index ba83e0aa2..273894fde 100644 --- a/src/librssguard/core/messageobject.h +++ b/src/librssguard/core/messageobject.h @@ -14,6 +14,8 @@ class MessageObject : public QObject { Q_PROPERTY(QList availableLabels READ availableLabels) Q_PROPERTY(QString feedCustomId READ feedCustomId) Q_PROPERTY(int accountId READ accountId) + Q_PROPERTY(int id READ id) + Q_PROPERTY(QString customId READ customId) Q_PROPERTY(QString title READ title WRITE setTitle) Q_PROPERTY(QString url READ url WRITE setUrl) Q_PROPERTY(QString author READ author WRITE setAuthor) @@ -56,7 +58,10 @@ class MessageObject : public QObject { // Compare with all messages from the account not only with messages from same feed. // Note that this value must be used via bitwise OR with other values, // for example 2 | 4 | 16. - AllFeedsSameAccount = 16 + AllFeedsSameAccount = 16, + + // Messages with same custom ID as provided by feed/service. + SameCustomId = 32 }; Q_ENUM(DuplicationAttributeCheck) @@ -91,8 +96,13 @@ class MessageObject : public QObject { // Generic Message's properties bindings. QString feedCustomId() const; + int accountId() const; + QString customId() const; + + int id() const; + QString title() const; void setTitle(const QString& title);