aboutsummaryrefslogtreecommitdiff
path: root/lib/events/eventcontent.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-09-13 19:14:19 +0200
committerTobias Fella <fella@posteo.de>2021-09-18 16:01:56 +0200
commitfe9425f313e7c172095ff9355743427337b7ea78 (patch)
tree28c24df409faca6e4d3f6863b1554e49d6b9d1cf /lib/events/eventcontent.cpp
parenta76ed82eb298d30c7b654c74378f93a9a35580a6 (diff)
downloadlibquotient-fe9425f313e7c172095ff9355743427337b7ea78.tar.gz
libquotient-fe9425f313e7c172095ff9355743427337b7ea78.zip
Add the encryptedfile to the eventcontent
Diffstat (limited to 'lib/events/eventcontent.cpp')
-rw-r--r--lib/events/eventcontent.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp
index 1f28f195..22878d4c 100644
--- a/lib/events/eventcontent.cpp
+++ b/lib/events/eventcontent.cpp
@@ -30,11 +30,12 @@ FileInfo::FileInfo(const QFileInfo &fi)
}
FileInfo::FileInfo(QUrl u, qint64 payloadSize, const QMimeType& mimeType,
- QString originalFilename)
+ Omittable<EncryptedFile> file, QString originalFilename)
: mimeType(mimeType)
, url(move(u))
, payloadSize(payloadSize)
, originalName(move(originalFilename))
+ , file(file)
{
if (!isValid())
qCWarning(MESSAGES)
@@ -44,6 +45,7 @@ FileInfo::FileInfo(QUrl u, qint64 payloadSize, const QMimeType& mimeType,
}
FileInfo::FileInfo(QUrl mxcUrl, const QJsonObject& infoJson,
+ const Omittable<EncryptedFile> &file,
QString originalFilename)
: originalInfoJson(infoJson)
, mimeType(
@@ -51,7 +53,11 @@ FileInfo::FileInfo(QUrl mxcUrl, const QJsonObject& infoJson,
, url(move(mxcUrl))
, payloadSize(fromJson<qint64>(infoJson["size"_ls]))
, originalName(move(originalFilename))
+ , file(file)
{
+ if(url.isEmpty() && file.has_value()) {
+ url = file->url;
+ }
if (!mimeType.isValid())
mimeType = QMimeDatabase().mimeTypeForData(QByteArray());
}
@@ -76,14 +82,15 @@ ImageInfo::ImageInfo(const QFileInfo& fi, QSize imageSize)
{}
ImageInfo::ImageInfo(const QUrl& mxcUrl, qint64 fileSize, const QMimeType& type,
- QSize imageSize, const QString& originalFilename)
- : FileInfo(mxcUrl, fileSize, type, originalFilename)
+ QSize imageSize, const Omittable<EncryptedFile> &file, const QString& originalFilename)
+ : FileInfo(mxcUrl, fileSize, type, file, originalFilename)
, imageSize(imageSize)
{}
ImageInfo::ImageInfo(const QUrl& mxcUrl, const QJsonObject& infoJson,
+ const Omittable<EncryptedFile> &file,
const QString& originalFilename)
- : FileInfo(mxcUrl, infoJson, originalFilename)
+ : FileInfo(mxcUrl, infoJson, file, originalFilename)
, imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt())
{}
@@ -96,9 +103,10 @@ void ImageInfo::fillInfoJson(QJsonObject* infoJson) const
infoJson->insert(QStringLiteral("h"), imageSize.height());
}
-Thumbnail::Thumbnail(const QJsonObject& infoJson)
+Thumbnail::Thumbnail(const QJsonObject& infoJson, const Omittable<EncryptedFile> &file)
: ImageInfo(QUrl(infoJson["thumbnail_url"_ls].toString()),
- infoJson["thumbnail_info"_ls].toObject())
+ infoJson["thumbnail_info"_ls].toObject(),
+ file)
{}
void Thumbnail::fillInfoJson(QJsonObject* infoJson) const