Move environment variable parsing and storage to its own class

Make the Link resolver and Twitch emotes set resolver urls modifiable with
environment variables
This commit is contained in:
Rasmus Karlsson
2019-05-26 21:44:13 +02:00
parent acf69139b9
commit 8ba8bbeef6
5 changed files with 24 additions and 22 deletions
+2 -3
View File
@@ -3,6 +3,7 @@
#include <QThread>
#include "Application.hpp"
#include "common/Env.hpp"
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
@@ -534,9 +535,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
return;
}
NetworkRequest req(
"https://braize.pajlada.com/chatterino/twitchemotes/set/" +
emoteSet->key + "/");
NetworkRequest req(Env::get().twitchEmoteSetResolverUrl.arg(emoteSet->key));
req.setUseQuickLoadCache(true);
req.onError([](int errorCode) -> bool {
+3 -13
View File
@@ -2,6 +2,7 @@
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/Env.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/notifications/NotificationController.hpp"
@@ -607,19 +608,8 @@ void TwitchChannel::loadRecentMessages()
return;
}
static QString genericURL = [] {
QString url("https://recent-messages.robotty.de/api/v2/recent-messages/"
"%1?clearchatToNotice=true");
auto envString = std::getenv("CHATTERINO2_RECENT_MESSAGES_URL");
if (envString != nullptr)
{
url = envString;
}
return url;
}();
NetworkRequest request(genericURL.arg(this->getName()));
NetworkRequest request(
Env::get().recentMessagesApiUrl.arg(this->getName()));
request.setCaller(QThread::currentThread());
// can't be concurrent right now due to SignalVector
// request.setExecuteConcurrently(true);