From 1f85375dfff4b64b73ed17c187732bb0d8773c5e Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 23 Nov 2022 08:03:47 +0100 Subject: [PATCH] ability to add article attachments directly from article filters --- .../io.github.martinrotter.rssguard.metainfo.xml | 2 +- resources/docs/Documentation.md | 15 ++++++++------- src/librssguard/core/messageobject.cpp | 4 ++++ src/librssguard/core/messageobject.h | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml b/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml index f7ee39586..63403b755 100644 --- a/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml +++ b/resources/desktop/io.github.martinrotter.rssguard.metainfo.xml @@ -60,7 +60,7 @@ - + rssguard diff --git a/resources/docs/Documentation.md b/resources/docs/Documentation.md index 1fcc20031..6d1da6cdd 100644 --- a/resources/docs/Documentation.md +++ b/resources/docs/Documentation.md @@ -143,10 +143,11 @@ Here is the reference of methods and properties of types available in your filte | Property | `isRead` | `Boolean` | ❌ | ✅ | Is message read? | Property | `isImportant` | `Boolean` | ❌ | ✅ | Is message important? | Property | `isDeleted` | `Boolean` | ❌ | ❌ | Is message placed in recycle bin? -| Method | `isAlreadyInDatabase(DuplicateCheck)` | `Boolean` | ❌ | ❌ | Allows you to test if this particular message is already stored in RSS Guard's DB. -| Method | `findLabelId(String)` | `String` | ❌ | ❌ | You enter title of the label and method returns `customId` of label which then can be used in `assignLabel()` and `deassignLabel` methods. -| Method | `assignLabel(String)` | `Boolean` | ❌ | ❌ | Assigns label to this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. -| Method | `deassignLabel(String)` | `Boolean` | ❌ | ❌ | Removes label from this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. +| Method | `addEnclosure(String url, String mime_type)` | `void` | ❌ | ❌ | Adds multimedia attachment to the article. +| Method | `isAlreadyInDatabase(DuplicateCheck criteria)` | `Boolean` | ❌ | ❌ | Allows you to test if this particular message is already stored in RSS Guard's DB. +| Method | `findLabelId(String label_name)` | `String` | ❌ | ❌ | You enter title of the label and method returns `customId` of label which then can be used in `assignLabel()` and `deassignLabel` methods. +| Method | `assignLabel(String label_id)` | `Boolean` | ❌ | ❌ | Assigns label to this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. +| Method | `deassignLabel(String label_id)` | `Boolean` | ❌ | ❌ | Removes label from this message. The passed `String` value is the `customId` property of `Label` type. See its API reference for relevant info. | Property | `runningFilterWhenFetching` | `Boolean` | ✅ | ❌ | Returns `true` if current run of the message filter is done when message is fetched. Returns `false` if message filter runs manually, for example from `Article filters` window. #### `Label` class @@ -179,9 +180,9 @@ Note that `MessageObject` attributes are synchronized with service even if you r | Type | Name(Parameter) | Return value | How to call | Description | :--- | :--- | :--- | :--- | --- | Method | `hostname()` | `String` | `utils.hostname()` | Returns name of your PC. -| Method | `fromXmlToJson(String)` | `String` | `utils.fromXmlToJson('

hello

')` | Converts `XML` string into `JSON`. -| Method | `parseDateTime(String)` | `Date` | `utils.parseDateTime('2020-02-24T08:00:00')` | Converts textual date/time representation into proper `Date` object. -| Method | `runExecutableGetOutput(String, String[])` | `String` | `utils.runExecutableGetOutput('cmd.exe', ['/c', 'dir'])` | Launches external executable with optional parameters, reads its standard output and returns the output when executable finishes. +| Method | `fromXmlToJson(String xml_string)` | `String` | `utils.fromXmlToJson('

hello

')` | Converts `XML` string into `JSON`. +| Method | `parseDateTime(String date_time)` | `Date` | `utils.parseDateTime('2020-02-24T08:00:00')` | Converts textual date/time representation into proper `Date` object. +| Method | `runExecutableGetOutput(String exec, String[] params)` | `String` | `utils.runExecutableGetOutput('cmd.exe', ['/c', 'dir'])` | Launches external executable with optional parameters, reads its standard output and returns the output when executable finishes. #### Examples Accept only messages/articles with title containing "Series Name" or "Another series" in it (whitelist): diff --git a/src/librssguard/core/messageobject.cpp b/src/librssguard/core/messageobject.cpp index 692fdee08..404334273 100644 --- a/src/librssguard/core/messageobject.cpp +++ b/src/librssguard/core/messageobject.cpp @@ -153,6 +153,10 @@ QString MessageObject::findLabelId(const QString& label_title) const { return found_lbl != nullptr ? found_lbl->customId() : QString(); } +void MessageObject::addEnclosure(const QString& url, const QString& mime_type) const { + m_message->m_enclosures.append(Enclosure(url, mime_type)); +} + QString MessageObject::title() const { return m_message->m_title; } diff --git a/src/librssguard/core/messageobject.h b/src/librssguard/core/messageobject.h index 60d4a20f9..c99a09034 100644 --- a/src/librssguard/core/messageobject.h +++ b/src/librssguard/core/messageobject.h @@ -92,6 +92,9 @@ class MessageObject : public QObject { // Returns label custom ID given label title. Q_INVOKABLE QString findLabelId(const QString& label_title) const; + // Add multimedia attachment to the message. + Q_INVOKABLE void addEnclosure(const QString& url, const QString& mime_type) const; + // Returns list of assigned and available messages. QList assignedLabels() const; QList availableLabels() const;