Sync changes in messages when marked more than 1000 messages read/unread/starred in gmail. Also make sure that all messages states are synced when marking whole account read/unread.
This commit is contained in:
parent
f78fa305ca
commit
2a36425b94
5 changed files with 46 additions and 26 deletions
|
@ -30,7 +30,7 @@
|
||||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="3.8.4" date="2020-12-31"/>
|
<release version="3.8.4" date="2021-01-01"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
|
|
@ -75,7 +75,7 @@ RSS Guard is simple (yet powerful) feed reader. It is able to fetch the most kno
|
||||||
* Windows Vista and newer,
|
* Windows Vista and newer,
|
||||||
* GNU/Linux,
|
* GNU/Linux,
|
||||||
* Mac OS X,
|
* Mac OS X,
|
||||||
* Android (buildable and running).
|
* Android (prebuilt binaries N/A at this point).
|
||||||
|
|
||||||
## List of main features
|
## List of main features
|
||||||
* **support for online feed synchronization via plugins**,
|
* **support for online feed synchronization via plugins**,
|
||||||
|
|
|
@ -1539,7 +1539,7 @@ QStringList DatabaseQueries::customIdsOfMessagesFromAccount(const QSqlDatabase&
|
||||||
QStringList ids;
|
QStringList ids;
|
||||||
|
|
||||||
q.setForwardOnly(true);
|
q.setForwardOnly(true);
|
||||||
q.prepare(QSL("SELECT custom_id FROM Messages WHERE is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;"));
|
q.prepare(QSL("SELECT custom_id FROM Messages WHERE is_pdeleted = 0 AND account_id = :account_id;"));
|
||||||
q.bindValue(QSL(":account_id"), account_id);
|
q.bindValue(QSL(":account_id"), account_id);
|
||||||
|
|
||||||
if (ok != nullptr) {
|
if (ok != nullptr) {
|
||||||
|
|
|
@ -220,8 +220,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id, Feed::Sta
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status,
|
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, QStringList custom_ids) {
|
||||||
const QStringList& custom_ids) {
|
|
||||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||||
|
|
||||||
if (bearer.isEmpty()) {
|
if (bearer.isEmpty()) {
|
||||||
|
@ -250,21 +249,31 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::Read
|
||||||
|
|
||||||
param_obj["addLabelIds"] = param_add;
|
param_obj["addLabelIds"] = param_add;
|
||||||
param_obj["removeLabelIds"] = param_remove;
|
param_obj["removeLabelIds"] = param_remove;
|
||||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
|
||||||
|
|
||||||
QJsonDocument param_doc(param_obj);
|
// We need to operate withing allowed batches.
|
||||||
QByteArray output;
|
for (int i = 0; i < custom_ids.size(); i += GMAIL_MAX_BATCH_SIZE) {
|
||||||
|
auto batch = custom_ids.mid(i, GMAIL_MAX_BATCH_SIZE);
|
||||||
|
|
||||||
return NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
param_obj["ids"] = QJsonArray::fromStringList(batch);
|
||||||
timeout,
|
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
QJsonDocument param_doc(param_obj);
|
||||||
output,
|
QByteArray output;
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||||
headers).first;
|
timeout,
|
||||||
|
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
|
output,
|
||||||
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
|
headers).first;
|
||||||
|
|
||||||
|
if (result != QNetworkReply::NetworkError::NoError) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QNetworkReply::NetworkError::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance,
|
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids) {
|
||||||
const QStringList& custom_ids) {
|
|
||||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||||
|
|
||||||
if (bearer.isEmpty()) {
|
if (bearer.isEmpty()) {
|
||||||
|
@ -293,17 +302,28 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::I
|
||||||
|
|
||||||
param_obj["addLabelIds"] = param_add;
|
param_obj["addLabelIds"] = param_add;
|
||||||
param_obj["removeLabelIds"] = param_remove;
|
param_obj["removeLabelIds"] = param_remove;
|
||||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
|
||||||
|
|
||||||
QJsonDocument param_doc(param_obj);
|
// We need to operate withing allowed batches.
|
||||||
QByteArray output;
|
for (int i = 0; i < custom_ids.size(); i += GMAIL_MAX_BATCH_SIZE) {
|
||||||
|
auto batch = custom_ids.mid(i, GMAIL_MAX_BATCH_SIZE);
|
||||||
|
|
||||||
return NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
param_obj["ids"] = QJsonArray::fromStringList(batch);
|
||||||
timeout,
|
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
QJsonDocument param_doc(param_obj);
|
||||||
output,
|
QByteArray output;
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||||
headers).first;
|
timeout,
|
||||||
|
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
|
output,
|
||||||
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
|
headers).first;
|
||||||
|
|
||||||
|
if (result != QNetworkReply::NetworkError::NoError) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QNetworkReply::NetworkError::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GmailNetworkFactory : public QObject {
|
||||||
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id);
|
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id);
|
||||||
|
|
||||||
QList<Message> messages(const QString& stream_id, Feed::Status& error);
|
QList<Message> messages(const QString& stream_id, Feed::Status& error);
|
||||||
QNetworkReply::NetworkError markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids);
|
QNetworkReply::NetworkError markMessagesRead(RootItem::ReadStatus status, QStringList custom_ids);
|
||||||
QNetworkReply::NetworkError markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids);
|
QNetworkReply::NetworkError markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Add table
Reference in a new issue