mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 17:15:01 +01:00
download all messages with greader, REALLY ALL if user wants to
This commit is contained in:
parent
3b9cdb477b
commit
465f5d254f
@ -134,23 +134,31 @@ QNetworkReply::NetworkError GreaderNetwork::markMessagesStarred(RootItem::Import
|
|||||||
|
|
||||||
QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString& stream_id,
|
QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString& stream_id,
|
||||||
Feed::Status& error, const QNetworkProxy& proxy) {
|
Feed::Status& error, const QNetworkProxy& proxy) {
|
||||||
QString full_url = generateFullUrl(Operations::StreamContents).arg(m_service == GreaderServiceRoot::Service::TheOldReader
|
QString continuation;
|
||||||
? stream_id
|
|
||||||
: QUrl::toPercentEncoding(stream_id),
|
|
||||||
QString::number(batchSize() <= 0
|
|
||||||
? 2000000
|
|
||||||
: batchSize()));
|
|
||||||
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
|
||||||
|
|
||||||
if (!ensureLogin(proxy)) {
|
if (!ensureLogin(proxy)) {
|
||||||
error = Feed::Status::AuthError;
|
error = Feed::Status::AuthError;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Message> msgs;
|
||||||
|
int target_msgs_size = batchSize() <= 0 ? 2000000: batchSize();
|
||||||
|
|
||||||
|
do {
|
||||||
|
QString full_url = generateFullUrl(Operations::StreamContents).arg(m_service == GreaderServiceRoot::Service::TheOldReader
|
||||||
|
? stream_id
|
||||||
|
: QUrl::toPercentEncoding(stream_id),
|
||||||
|
QString::number(target_msgs_size));
|
||||||
|
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
|
||||||
if (downloadOnlyUnreadMessages()) {
|
if (downloadOnlyUnreadMessages()) {
|
||||||
full_url += QSL("&xt=%1").arg(GREADER_API_FULL_STATE_READ);
|
full_url += QSL("&xt=%1").arg(GREADER_API_FULL_STATE_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!continuation.isEmpty()) {
|
||||||
|
full_url += QSL("&c=%1").arg(continuation);
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray output_stream;
|
QByteArray output_stream;
|
||||||
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
||||||
timeout,
|
timeout,
|
||||||
@ -173,9 +181,13 @@ QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString&
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error = Feed::Status::Normal;
|
msgs.append(decodeStreamContents(root, output_stream, stream_id, continuation));
|
||||||
return decodeStreamContents(root, output_stream, stream_id);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
while (!continuation.isEmpty() && msgs.size() < target_msgs_size);
|
||||||
|
|
||||||
|
error = Feed::Status::Normal;
|
||||||
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* GreaderNetwork::categoriesFeedsLabelsTree(bool obtain_icons, const QNetworkProxy& proxy) {
|
RootItem* GreaderNetwork::categoriesFeedsLabelsTree(bool obtain_icons, const QNetworkProxy& proxy) {
|
||||||
@ -539,11 +551,14 @@ QString GreaderNetwork::simplifyStreamId(const QString& stream_id) const {
|
|||||||
|
|
||||||
QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
|
QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
|
||||||
const QString& stream_json_data,
|
const QString& stream_json_data,
|
||||||
const QString& stream_id) {
|
const QString& stream_id,
|
||||||
|
QString& continuation) {
|
||||||
QList<Message> messages;
|
QList<Message> messages;
|
||||||
QJsonArray json = QJsonDocument::fromJson(stream_json_data.toUtf8()).object()["items"].toArray();
|
QJsonDocument json_doc = QJsonDocument::fromJson(stream_json_data.toUtf8());
|
||||||
|
QJsonArray json = json_doc.object()["items"].toArray();
|
||||||
auto active_labels = root->labelsNode() != nullptr ? root->labelsNode()->labels() : QList<Label*>();
|
auto active_labels = root->labelsNode() != nullptr ? root->labelsNode()->labels() : QList<Label*>();
|
||||||
|
|
||||||
|
continuation = json_doc.object()["continuation"].toString();
|
||||||
messages.reserve(json.count());
|
messages.reserve(json.count());
|
||||||
|
|
||||||
for (const QJsonValue& obj : json) {
|
for (const QJsonValue& obj : json) {
|
||||||
|
@ -78,7 +78,7 @@ class GreaderNetwork : public QObject {
|
|||||||
bool ensureLogin(const QNetworkProxy& proxy, QNetworkReply::NetworkError* output = nullptr);
|
bool ensureLogin(const QNetworkProxy& proxy, QNetworkReply::NetworkError* output = nullptr);
|
||||||
|
|
||||||
QString simplifyStreamId(const QString& stream_id) const;
|
QString simplifyStreamId(const QString& stream_id) const;
|
||||||
QList<Message> decodeStreamContents(ServiceRoot* root, const QString& stream_json_data, const QString& stream_id);
|
QList<Message> decodeStreamContents(ServiceRoot* root, const QString& stream_json_data, const QString& stream_id, QString& continuation);
|
||||||
RootItem* decodeTagsSubscriptions(const QString& categories, const QString& feeds, bool obtain_icons, const QNetworkProxy& proxy);
|
RootItem* decodeTagsSubscriptions(const QString& categories, const QString& feeds, bool obtain_icons, const QNetworkProxy& proxy);
|
||||||
QString sanitizedBaseUrl() const;
|
QString sanitizedBaseUrl() const;
|
||||||
QString generateFullUrl(Operations operation) const;
|
QString generateFullUrl(Operations operation) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user