mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-02 18:36:49 +01:00
semi-fix to allow workaround for broken label assignment
This commit is contained in:
parent
459826ecfb
commit
f0bb361e6f
@ -132,7 +132,7 @@ Here is the reference of methods and properties of types available in your filte
|
||||
| Property | `feedCustomId` | `String` | ✅ | ❌ | Service-specific ID of the feed which this message belongs to.
|
||||
| Property | `accountId` | `Number` | ✅ | ❌ | RSS Guard's ID of the account activated in the program. This property is highly advanced and you probably do not need to use it at all.
|
||||
| Property | `id` | `Number` | ✅ | ❌ | ID assigned to the message in RSS Guard local database.
|
||||
| Property | `customId` | `String` | ✅ | ❌ | ID of the message as provided by the remote service or feed file.
|
||||
| Property | `customId` | `String` | ❌ | ❌ | ID of the message as provided by the remote service or feed file.
|
||||
| Property | `title` | `String` | ❌ | ❌ | Title of the message.
|
||||
| Property | `url` | `String` | ❌ | ❌ | URL of the message.
|
||||
| Property | `author` | `String` | ❌ | ❌ | Author of the message.
|
||||
|
@ -235,12 +235,12 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
||||
QList<Message> read_msgs, important_msgs;
|
||||
|
||||
for (int i = 0; i < msgs.size(); i++) {
|
||||
Message msg_backup(msgs[i]);
|
||||
Message* msg_orig = &msgs[i];
|
||||
Message msg_original(msgs[i]);
|
||||
Message* msg_tweaked_by_filter = &msgs[i];
|
||||
|
||||
// Attach live message object to wrapper.
|
||||
tmr.restart();
|
||||
msg_obj.setMessage(msg_orig);
|
||||
msg_obj.setMessage(msg_tweaked_by_filter);
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Hooking message took " << tmr.nsecsElapsed() / 1000 << " microseconds.";
|
||||
|
||||
auto feed_filters = feed->messageFilters();
|
||||
@ -291,39 +291,41 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!msg_backup.m_isRead && msg_orig->m_isRead) {
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId
|
||||
if (!msg_original.m_isRead && msg_tweaked_by_filter->m_isRead) {
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_original.m_customId
|
||||
<< "' was marked as read by message scripts.";
|
||||
|
||||
read_msgs << *msg_orig;
|
||||
read_msgs << *msg_tweaked_by_filter;
|
||||
}
|
||||
|
||||
if (!msg_backup.m_isImportant && msg_orig->m_isImportant) {
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_backup.m_customId
|
||||
if (!msg_original.m_isImportant && msg_tweaked_by_filter->m_isImportant) {
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Message with custom ID: '" << msg_original.m_customId
|
||||
<< "' was marked as important by message scripts.";
|
||||
|
||||
important_msgs << *msg_orig;
|
||||
important_msgs << *msg_tweaked_by_filter;
|
||||
}
|
||||
|
||||
// Process changed labels.
|
||||
for (Label* lbl : qAsConst(msg_backup.m_assignedLabels)) {
|
||||
if (!msg_orig->m_assignedLabels.contains(lbl)) {
|
||||
for (Label* lbl : qAsConst(msg_original.m_assignedLabels)) {
|
||||
if (!msg_tweaked_by_filter->m_assignedLabels.contains(lbl)) {
|
||||
// Label is not there anymore, it was deassigned.
|
||||
lbl->deassignFromMessage(*msg_orig);
|
||||
lbl->deassignFromMessage(*msg_tweaked_by_filter);
|
||||
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "It was detected that label" << QUOTE_W_SPACE(lbl->customId())
|
||||
<< "was DEASSIGNED from message" << QUOTE_W_SPACE(msg_orig->m_customId) << "by message filter(s).";
|
||||
<< "was DEASSIGNED from message" << QUOTE_W_SPACE(msg_tweaked_by_filter->m_customId)
|
||||
<< "by message filter(s).";
|
||||
}
|
||||
}
|
||||
|
||||
for (Label* lbl : qAsConst(msg_orig->m_assignedLabels)) {
|
||||
if (!msg_backup.m_assignedLabels.contains(lbl)) {
|
||||
for (Label* lbl : qAsConst(msg_tweaked_by_filter->m_assignedLabels)) {
|
||||
if (!msg_original.m_assignedLabels.contains(lbl)) {
|
||||
// Label is in new message, but is not in old message, it
|
||||
// was newly assigned.
|
||||
lbl->assignToMessage(*msg_orig);
|
||||
lbl->assignToMessage(*msg_tweaked_by_filter);
|
||||
|
||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "It was detected that label" << QUOTE_W_SPACE(lbl->customId())
|
||||
<< "was ASSIGNED to message" << QUOTE_W_SPACE(msg_orig->m_customId) << "by message filter(s).";
|
||||
<< "was ASSIGNED to message" << QUOTE_W_SPACE(msg_tweaked_by_filter->m_customId)
|
||||
<< "by message filter(s).";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,10 @@ QString MessageObject::customId() const {
|
||||
return m_message->m_customId;
|
||||
}
|
||||
|
||||
void MessageObject::setCustomId(const QString& custom_id) {
|
||||
m_message->m_customId = custom_id;
|
||||
}
|
||||
|
||||
int MessageObject::id() const {
|
||||
return m_message->m_id;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class MessageObject : public QObject {
|
||||
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 customId READ customId WRITE setCustomId)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||
Q_PROPERTY(QString url READ url WRITE setUrl)
|
||||
Q_PROPERTY(QString author READ author WRITE setAuthor)
|
||||
@ -104,6 +104,7 @@ class MessageObject : public QObject {
|
||||
int accountId() const;
|
||||
|
||||
QString customId() const;
|
||||
void setCustomId(const QString& custom_id);
|
||||
|
||||
int id() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user