Skip to content

Commit

Permalink
Fix downloading encrypted files; make failed MxcReply more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal committed Dec 20, 2022
1 parent 7f05dc9 commit 2d10238
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
13 changes: 7 additions & 6 deletions lib/mxcreply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class MxcReply::Private
}
};

MxcReply::MxcReply(QNetworkReply* reply) : d(makeImpl<Private>())
MxcReply::MxcReply(DeferredFlag) : d(makeImpl<Private>()) {}

MxcReply::MxcReply(QNetworkReply* reply) : MxcReply(Deferred)
{
setNetworkReply(reply);
}

MxcReply::MxcReply(DeferredFlag) : d(makeImpl<Private>()) {}

MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId)
: MxcReply(reply)
MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString& eventId)
: MxcReply(Deferred)
{
#ifdef Quotient_E2EE_ENABLED
if (auto eventIt = room->findInTimeline(eventId);
Expand All @@ -48,6 +48,7 @@ MxcReply::MxcReply(QNetworkReply* reply, Room* room, const QString &eventId)
}
}
#endif
setNetworkReply(reply);
}

void MxcReply::setNetworkReply(QNetworkReply* newReply)
Expand Down Expand Up @@ -77,7 +78,7 @@ void MxcReply::setNetworkReply(QNetworkReply* newReply)
});
}

MxcReply::MxcReply()
MxcReply::MxcReply(FailedFlag)
: d(ZeroImpl<Private>())
{
static const auto BadRequestPhrase = tr("Bad Request");
Expand Down
5 changes: 3 additions & 2 deletions lib/mxcreply.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class QUOTIENT_API MxcReply : public QNetworkReply
Q_OBJECT
public:
enum DeferredFlag { Deferred };
enum FailedFlag { Failed };

explicit MxcReply();
explicit MxcReply(QNetworkReply *reply);
explicit MxcReply(DeferredFlag);
explicit MxcReply(FailedFlag);
explicit MxcReply(QNetworkReply *reply);
MxcReply(QNetworkReply* reply, Room* room, const QString& eventId);

void setNetworkReply(QNetworkReply* newReply);
Expand Down
6 changes: 3 additions & 3 deletions lib/networkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ QNetworkReply* NetworkAccessManager::createRequest(
if (accountId.isEmpty()) {
if (!directMediaRequestsAllowed()) {
qCWarning(NETWORK) << "No connection specified";
return new MxcReply();
return new MxcReply(MxcReply::Failed);
}
// Best effort with an unauthenticated request directly to the media
// homeserver (rather than via own homeserver)
Expand All @@ -115,7 +115,7 @@ QNetworkReply* NetworkAccessManager::createRequest(
const auto* const connection = Accounts.get(accountId);
if (!connection) {
qCWarning(NETWORK) << "Connection" << accountId << "not found";
return new MxcReply();
return new MxcReply(MxcReply::Failed);
}
if (const auto roomId =
query.queryItemValue(QStringLiteral("room_id"));
Expand All @@ -126,7 +126,7 @@ QNetworkReply* NetworkAccessManager::createRequest(
query.queryItemValue(QStringLiteral("event_id")));

qCWarning(NETWORK) << "Room" << roomId << "not found";
return new MxcReply();
return new MxcReply(MxcReply::Failed);
}
return new MxcReply(
d->createImplRequest(op, request, connection));
Expand Down

0 comments on commit 2d10238

Please sign in to comment.