mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-01 02:48:05 +01:00
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
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.8.4" date="2020-12-31"/>
|
||||
<release version="3.8.4" date="2021-01-01"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<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,
|
||||
* GNU/Linux,
|
||||
* Mac OS X,
|
||||
* Android (buildable and running).
|
||||
* Android (prebuilt binaries N/A at this point).
|
||||
|
||||
## List of main features
|
||||
* **support for online feed synchronization via plugins**,
|
||||
|
@ -1539,7 +1539,7 @@ QStringList DatabaseQueries::customIdsOfMessagesFromAccount(const QSqlDatabase&
|
||||
QStringList ids;
|
||||
|
||||
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);
|
||||
|
||||
if (ok != nullptr) {
|
||||
|
@ -220,8 +220,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id, Feed::Sta
|
||||
return messages;
|
||||
}
|
||||
|
||||
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status,
|
||||
const QStringList& custom_ids) {
|
||||
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, QStringList custom_ids) {
|
||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||
|
||||
if (bearer.isEmpty()) {
|
||||
@ -250,21 +249,31 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::Read
|
||||
|
||||
param_obj["addLabelIds"] = param_add;
|
||||
param_obj["removeLabelIds"] = param_remove;
|
||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
||||
|
||||
QJsonDocument param_doc(param_obj);
|
||||
QByteArray output;
|
||||
// We need to operate withing allowed batches.
|
||||
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,
|
||||
timeout,
|
||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||
output,
|
||||
QNetworkAccessManager::Operation::PostOperation,
|
||||
headers).first;
|
||||
param_obj["ids"] = QJsonArray::fromStringList(batch);
|
||||
|
||||
QJsonDocument param_doc(param_obj);
|
||||
QByteArray output;
|
||||
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||
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,
|
||||
const QStringList& custom_ids) {
|
||||
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids) {
|
||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||
|
||||
if (bearer.isEmpty()) {
|
||||
@ -293,17 +302,28 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::I
|
||||
|
||||
param_obj["addLabelIds"] = param_add;
|
||||
param_obj["removeLabelIds"] = param_remove;
|
||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
||||
|
||||
QJsonDocument param_doc(param_obj);
|
||||
QByteArray output;
|
||||
// We need to operate withing allowed batches.
|
||||
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,
|
||||
timeout,
|
||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||
output,
|
||||
QNetworkAccessManager::Operation::PostOperation,
|
||||
headers).first;
|
||||
param_obj["ids"] = QJsonArray::fromStringList(batch);
|
||||
|
||||
QJsonDocument param_doc(param_obj);
|
||||
QByteArray output;
|
||||
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||
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) {
|
||||
|
@ -41,7 +41,7 @@ class GmailNetworkFactory : public QObject {
|
||||
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id);
|
||||
|
||||
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);
|
||||
|
||||
private slots:
|
||||
|
Loading…
Reference in New Issue
Block a user