replace invalid article dates with current date, fix date/time for gmail when standard "Date" header is missing
This commit is contained in:
parent
dcafe45a23
commit
a639f06891
@ -101,10 +101,9 @@ void Message::sanitize(const Feed* feed, bool fix_future_datetimes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix datetimes in future.
|
// Fix datetimes in future.
|
||||||
if (fix_future_datetimes &&
|
if ((fix_future_datetimes && m_createdFromFeed && m_created.toUTC() > QDateTime::currentDateTimeUtc()) ||
|
||||||
m_createdFromFeed &&
|
(m_createdFromFeed && !m_created.isValid())) {
|
||||||
m_created.toUTC() > QDateTime::currentDateTimeUtc()) {
|
qWarningNN << LOGSEC_CORE << "Fixing date of article" << QUOTE_W_SPACE(m_title) << "from invalid date/time"
|
||||||
qWarningNN << LOGSEC_CORE << "Fixing future date of article" << QUOTE_W_SPACE(m_title) << "from invalid date/time"
|
|
||||||
<< QUOTE_W_SPACE_DOT(m_created);
|
<< QUOTE_W_SPACE_DOT(m_created);
|
||||||
|
|
||||||
m_createdFromFeed = false;
|
m_createdFromFeed = false;
|
||||||
|
@ -189,6 +189,8 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool is_spam_feed = QString::compare(stream_id, QSL("SPAM"), Qt::CaseSensitivity::CaseInsensitive) == 0;
|
||||||
|
|
||||||
// 1. Get unread IDs for a feed.
|
// 1. Get unread IDs for a feed.
|
||||||
// 2. Get read IDs for a feed.
|
// 2. Get read IDs for a feed.
|
||||||
// 3. Get starred IDs for a feed.
|
// 3. Get starred IDs for a feed.
|
||||||
@ -196,11 +198,11 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
|
|||||||
QStringList remote_read_ids_list, remote_unread_ids_list, remote_starred_ids_list;
|
QStringList remote_read_ids_list, remote_unread_ids_list, remote_starred_ids_list;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
remote_starred_ids_list = list(stream_id, {}, 0, QSL("is:starred"), custom_proxy);
|
remote_starred_ids_list = list(stream_id, {}, 0, is_spam_feed, QSL("is:starred"), custom_proxy);
|
||||||
remote_unread_ids_list = list(stream_id, {}, batchSize(), QSL("is:unread"), custom_proxy);
|
remote_unread_ids_list = list(stream_id, {}, batchSize(), is_spam_feed, QSL("is:unread"), custom_proxy);
|
||||||
|
|
||||||
if (!downloadOnlyUnreadMessages()) {
|
if (!downloadOnlyUnreadMessages()) {
|
||||||
remote_read_ids_list = list(stream_id, {}, batchSize(), QSL("is:read"), custom_proxy);
|
remote_read_ids_list = list(stream_id, {}, batchSize(), is_spam_feed, QSL("is:read"), custom_proxy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const NetworkException& net_ex) {
|
catch (const NetworkException& net_ex) {
|
||||||
@ -379,6 +381,7 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::I
|
|||||||
QStringList GmailNetworkFactory::list(const QString& stream_id,
|
QStringList GmailNetworkFactory::list(const QString& stream_id,
|
||||||
const QStringList& label_ids,
|
const QStringList& label_ids,
|
||||||
int max_results,
|
int max_results,
|
||||||
|
bool include_spam,
|
||||||
const QString& query,
|
const QString& query,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
QList<QString> message_ids;
|
QList<QString> message_ids;
|
||||||
@ -401,6 +404,10 @@ QStringList GmailNetworkFactory::list(const QString& stream_id,
|
|||||||
target_url += QSL("&q=%1").arg(query);
|
target_url += QSL("&q=%1").arg(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (include_spam) {
|
||||||
|
target_url += QSL("&includeSpamTrash=true");
|
||||||
|
}
|
||||||
|
|
||||||
int remaining = max_results - message_ids.size();
|
int remaining = max_results - message_ids.size();
|
||||||
|
|
||||||
if (max_results <= 0 || remaining > 500) {
|
if (max_results <= 0 || remaining > 500) {
|
||||||
@ -550,6 +557,10 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
|
|||||||
msg.m_createdFromFeed = true;
|
msg.m_createdFromFeed = true;
|
||||||
msg.m_created = TextFactory::parseDateTime(headers[QSL("Date")]);
|
msg.m_created = TextFactory::parseDateTime(headers[QSL("Date")]);
|
||||||
|
|
||||||
|
if (!msg.m_created.isValid()) {
|
||||||
|
msg.m_created = TextFactory::parseDateTime(headers[QSL("date")]);
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.m_title.isEmpty()) {
|
if (msg.m_title.isEmpty()) {
|
||||||
msg.m_title = tr("No subject");
|
msg.m_title = tr("No subject");
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class GmailNetworkFactory : public QObject {
|
|||||||
QStringList list(const QString& stream_id,
|
QStringList list(const QString& stream_id,
|
||||||
const QStringList& label_ids,
|
const QStringList& label_ids,
|
||||||
int max_results,
|
int max_results,
|
||||||
|
bool include_spam,
|
||||||
const QString& query,
|
const QString& query,
|
||||||
const QNetworkProxy& custom_proxy);
|
const QNetworkProxy& custom_proxy);
|
||||||
QVariantHash getProfile(const QNetworkProxy& custom_proxy);
|
QVariantHash getProfile(const QNetworkProxy& custom_proxy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user