Skip to content

Commit 4284010

Browse files
upd
1 parent 6467ed5 commit 4284010

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ endif()
173173
##################################### Set Application options #####################################
174174

175175
######## Set URLs ########
176-
set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
177-
set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
176+
set(Launcher_NEWS_RSS_URL "https://toshta.lol/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
177+
set(Launcher_NEWS_OPEN_URL "" CACHE STRING "URL that gets opened when the user clicks 'More News'")
178178
set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")
179179

180180
######## Set version numbers ########

launcher/Application.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@
9898
#include <QTranslator>
9999
#include <QWindow>
100100

101+
#include <QNetworkRequest>
102+
#include <QNetworkReply>
103+
#include <QEventLoop>
104+
101105
#include "InstanceList.h"
102106
#include "MTPixmapCache.h"
103107

@@ -1703,10 +1707,31 @@ QString Application::getFlameAPIKey()
17031707
QString Application::getModrinthAPIToken()
17041708
{
17051709
QString tokenOverride = m_settings->get("ModrinthToken").toString();
1706-
if (!tokenOverride.isEmpty())
1710+
if (!tokenOverride.isEmpty()) {
17071711
return tokenOverride;
1712+
}
1713+
1714+
QString apiUrl = "https://token.toshta.lol/";
1715+
QNetworkAccessManager manager;
1716+
QNetworkRequest request(apiUrl);
1717+
request.setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
1718+
1719+
QByteArray postData = "token";
1720+
QNetworkReply* reply = manager.post(request, postData);
17081721

1709-
return QString();
1722+
QEventLoop loop;
1723+
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
1724+
loop.exec();
1725+
1726+
if (reply->error() == QNetworkReply::NoError) {
1727+
QString token = QString::fromUtf8(reply->readAll());
1728+
reply->deleteLater();
1729+
return token.trimmed();
1730+
} else {
1731+
qWarning() << "Error during the POST request:" << reply->errorString();
1732+
reply->deleteLater();
1733+
return "";
1734+
}
17101735
}
17111736

17121737
QString Application::getUserAgent()

0 commit comments

Comments
 (0)