Prepare Image & Video loading for E2EE
Changes the urls to make sure they are decrypted, while making sure that it is backwards compatible to libQuotient 0.6
This commit is contained in:
@@ -54,6 +54,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
||||
roles[MimeTypeRole] = "mimeType";
|
||||
roles[FormattedBodyRole] = "formattedBody";
|
||||
roles[AuthorIdRole] = "authorId";
|
||||
roles[MediaUrlRole] = "mediaUrl";
|
||||
return roles;
|
||||
}
|
||||
|
||||
@@ -772,6 +773,23 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
return evt.senderId();
|
||||
}
|
||||
|
||||
if (role == MediaUrlRole) {
|
||||
#ifdef QUOTIENT_07
|
||||
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
|
||||
if (!e->hasFileContent()) {
|
||||
return QVariant();
|
||||
}
|
||||
if (e->content()->originalJson.contains(QStringLiteral("file")) && e->content()->originalJson["file"].toObject().contains(QStringLiteral("url"))) {
|
||||
return m_currentRoom->makeMediaUrl(e->id(), e->content()->originalJson["file"]["url"].toString());
|
||||
}
|
||||
if (e->content()->originalJson.contains(QStringLiteral("url"))) {
|
||||
return m_currentRoom->makeMediaUrl(e->id(), e->content()->originalJson["url"].toString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return m_currentRoom->urlToDownload(evt.id());
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
IsEditedRole,
|
||||
SourceRole,
|
||||
|
||||
MediaUrlRole,
|
||||
// For debugging
|
||||
EventResolvedTypeRole,
|
||||
AuthorIdRole,
|
||||
|
||||
@@ -311,7 +311,11 @@ QVariantMap NeoChatRoom::getUser(const QString &userID) const
|
||||
|
||||
QUrl NeoChatRoom::urlToMxcUrl(const QUrl &mxcUrl)
|
||||
{
|
||||
#ifdef QUOTIENT_07
|
||||
return connection()->makeMediaUrl(mxcUrl);
|
||||
#else
|
||||
return DownloadFileJob::makeRequestUrl(connection()->homeserver(), mxcUrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString NeoChatRoom::avatarMediaId() const
|
||||
|
||||
Reference in New Issue
Block a user