diff options
Diffstat (limited to 'lib/events/eventcontent.cpp')
-rw-r--r-- | lib/events/eventcontent.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index cc31fea5..2b84c2b7 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -34,26 +34,31 @@ QJsonObject Base::toJson() const FileInfo::FileInfo(const QUrl& u, qint64 payloadSize, const QMimeType& mimeType, const QString& originalFilename) - : mimeType(mimeType), - url(u), - payloadSize(payloadSize), - originalName(originalFilename) -{ -} + : mimeType(mimeType) + , url(u) + , payloadSize(payloadSize) + , originalName(originalFilename) +{} FileInfo::FileInfo(const QUrl& u, const QJsonObject& infoJson, const QString& originalFilename) - : originalInfoJson(infoJson), - mimeType(QMimeDatabase().mimeTypeForName( - infoJson["mimetype"_ls].toString())), - url(u), - payloadSize(fromJson<qint64>(infoJson["size"_ls])), - originalName(originalFilename) + : originalInfoJson(infoJson) + , mimeType( + QMimeDatabase().mimeTypeForName(infoJson["mimetype"_ls].toString())) + , url(u) + , payloadSize(fromJson<qint64>(infoJson["size"_ls])) + , originalName(originalFilename) { if (!mimeType.isValid()) mimeType = QMimeDatabase().mimeTypeForData(QByteArray()); } +bool FileInfo::isValid() const +{ + return url.scheme() == "mxc" + && (url.authority() + url.path()).count('/') == 1; +} + void FileInfo::fillInfoJson(QJsonObject* infoJson) const { Q_ASSERT(infoJson); @@ -65,16 +70,15 @@ void FileInfo::fillInfoJson(QJsonObject* infoJson) const ImageInfo::ImageInfo(const QUrl& u, qint64 fileSize, QMimeType mimeType, const QSize& imageSize, const QString& originalFilename) - : FileInfo(u, fileSize, mimeType, originalFilename), imageSize(imageSize) -{ -} + : FileInfo(u, fileSize, mimeType, originalFilename) + , imageSize(imageSize) +{} ImageInfo::ImageInfo(const QUrl& u, const QJsonObject& infoJson, const QString& originalFilename) - : FileInfo(u, infoJson, originalFilename), - imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt()) -{ -} + : FileInfo(u, infoJson, originalFilename) + , imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt()) +{} void ImageInfo::fillInfoJson(QJsonObject* infoJson) const { @@ -88,8 +92,7 @@ void ImageInfo::fillInfoJson(QJsonObject* infoJson) const Thumbnail::Thumbnail(const QJsonObject& infoJson) : ImageInfo(infoJson["thumbnail_url"_ls].toString(), infoJson["thumbnail_info"_ls].toObject()) -{ -} +{} void Thumbnail::fillInfoJson(QJsonObject* infoJson) const { |