diff options
author | flow <flowlnlnln@gmail.com> | 2022-06-19 14:29:21 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-07-17 11:33:43 -0300 |
commit | 52c45c2d32e6bb10b2ca5db9b73cb91fac57c943 (patch) | |
tree | e649079aaef56c06f7329a51de48e371092d9c6e /launcher/modplatform/modrinth | |
parent | fd6755c93f3f3f7551f9b7c11d1bbbb48c22e210 (diff) | |
download | PrismLauncher-52c45c2d32e6bb10b2ca5db9b73cb91fac57c943.tar.gz PrismLauncher-52c45c2d32e6bb10b2ca5db9b73cb91fac57c943.tar.bz2 PrismLauncher-52c45c2d32e6bb10b2ca5db9b73cb91fac57c943.zip |
feat: add some mod api calls
- Get Project: Already existed but required a specific caller type. This
is more general.
- Get Projects: A single call to multiple of the above
Both providers support these calls.
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/modplatform/modrinth')
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthAPI.cpp | 15 | ||||
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthAPI.h | 8 |
2 files changed, 20 insertions, 3 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthAPI.cpp b/launcher/modplatform/modrinth/ModrinthAPI.cpp index 0d5d4bab..301c0be8 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.cpp +++ b/launcher/modplatform/modrinth/ModrinthAPI.cpp @@ -88,8 +88,19 @@ auto ModrinthAPI::latestVersions(const QStringList& hashes, QJsonDocument body(body_obj); auto body_raw = body.toJson(); - netJob->addNetAction(Net::Upload::makeByteArray( - QString(BuildConfig.MODRINTH_PROD_URL + "/version_files/update"), response, body_raw)); + netJob->addNetAction(Net::Upload::makeByteArray(QString(BuildConfig.MODRINTH_PROD_URL + "/version_files/update"), response, body_raw)); + + QObject::connect(netJob, &NetJob::finished, [response] { delete response; }); + + return netJob; +} + +auto ModrinthAPI::getProjects(QStringList addonIds, QByteArray* response) const -> NetJob::Ptr +{ + auto netJob = new NetJob(QString("Modrinth::GetProjects"), APPLICATION->network()); + auto searchUrl = getMultipleModInfoURL(addonIds); + + netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response)); QObject::connect(netJob, &NetJob::finished, [response] { delete response; }); diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h index 9694b85e..2909daf9 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.h +++ b/launcher/modplatform/modrinth/ModrinthAPI.h @@ -22,7 +22,6 @@ #include "modplatform/ModAPI.h" #include "modplatform/ModIndex.h" #include "modplatform/helpers/NetworkModAPI.h" -#include "net/NetJob.h" #include <QDebug> @@ -48,6 +47,8 @@ class ModrinthAPI : public NetworkModAPI { ModLoaderTypes loaders, QByteArray* response) -> NetJob::Ptr; + auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob::Ptr override; + public: inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; }; @@ -103,6 +104,11 @@ class ModrinthAPI : public NetworkModAPI { return BuildConfig.MODRINTH_PROD_URL + "/project/" + id; }; + inline auto getMultipleModInfoURL(QStringList ids) const -> QString + { + return BuildConfig.MODRINTH_PROD_URL + QString("/projects?ids=[\"%1\"]").arg(ids.join("\",\"")); + }; + inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override { return QString(BuildConfig.MODRINTH_PROD_URL + |