5 #include <Quotient/jobs/basejob.h>
7 #include <QtCore/QIODevice>
8 #include <QtNetwork/QNetworkReply>
36 explicit GetContentAuthedJob(
const QString& serverName,
const QString& mediaId,
37 qint64 timeoutMs = 20000);
43 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
44 const QString& mediaId, qint64 timeoutMs = 20000);
65 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
84 QString contentDisposition()
const
86 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
90 QIODevice* data() {
return reply(); }
124 explicit GetContentOverrideNameAuthedJob(
const QString& serverName,
const QString& mediaId,
125 const QString& fileName, qint64 timeoutMs = 20000);
131 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
132 const QString& mediaId,
const QString& fileName,
133 qint64 timeoutMs = 20000);
154 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
165 QString contentDisposition()
const
167 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
171 QIODevice* data() {
return reply(); }
229 explicit GetContentThumbnailAuthedJob(
const QString& serverName,
const QString& mediaId,
230 int width,
int height,
const QString& method = {},
231 qint64 timeoutMs = 20000,
232 std::optional<
bool> animated = std::nullopt);
238 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
239 const QString& mediaId,
int width,
int height,
240 const QString& method = {}, qint64 timeoutMs = 20000,
241 std::optional<
bool> animated = std::nullopt);
253 QString contentDisposition()
const
255 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
259 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
262 QIODevice* data() {
return reply(); }
284 explicit GetUrlPreviewAuthedJob(
const QUrl& url, std::optional<qint64> ts = std::nullopt);
290 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QUrl& url,
291 std::optional<qint64> ts = std::nullopt);
296 std::optional<qint64> matrixImageSize()
const
298 return loadFromJson<std::optional<qint64>>(
"matrix:image:size"_L1);
303 QUrl ogImage()
const {
return loadFromJson<QUrl>(
"og:image"_L1); }
307 std::optional<qint64> matrixImageSize{};
315 template <std::derived_from<GetUrlPreviewAuthedJob> JobT>
316 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> GetUrlPreviewAuthedJob::Response {
317 return { j->matrixImageSize(), j->ogImage() };
335 explicit GetConfigAuthedJob();
341 static QUrl makeRequestUrl(
const HomeserverData& hsData);
348 std::optional<qint64> uploadSize()
const
350 return loadFromJson<std::optional<qint64>>(
"m.upload.size"_L1);
354 inline auto collectResponse(
const GetConfigAuthedJob* job) {
return job->uploadSize(); }