better parsing of some gmail email messages

This commit is contained in:
Martin Rotter 2021-06-24 12:18:01 +02:00
parent 505af2c9f2
commit fa059d129a
2 changed files with 12 additions and 1 deletions

View File

@ -30,7 +30,7 @@
<url type="donation">https://martinrotter.github.io/donate/</url>
<content_rating type="oars-1.1" />
<releases>
<release version="3.9.2" date="2021-06-23"/>
<release version="3.9.2" date="2021-06-24"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -487,6 +487,8 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
msg.m_createdFromFeed = true;
msg.m_created = TextFactory::parseDateTime(headers["Date"]);
QString aa = msg.m_rawContents;
if (msg.m_title.isEmpty()) {
msg.m_title = tr("No subject");
}
@ -508,6 +510,10 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
}
}
if (json["payload"].toObject().contains(QSL("body"))) {
parts.prepend(json["payload"].toObject());
}
for (const QJsonObject& part : qAsConst(parts)) {
QJsonObject body = part["body"].toObject();
QString mime = part["mimeType"].toString();
@ -522,6 +528,11 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
}
else if (backup_contents.isEmpty()) {
backup_contents = QByteArray::fromBase64(body["data"].toString().toUtf8(), QByteArray::Base64Option::Base64UrlEncoding);
backup_contents = backup_contents
.replace(QSL("\r\n"), QSL("\n"))
.replace(QSL("\n"), QSL("\n"))
.replace(QSL("\n"), QSL("<br/>"));
}
}
}