Skip to content

Commit 69907b5

Browse files
committed
fixes
1 parent d416e85 commit 69907b5

5 files changed

Lines changed: 16 additions & 11 deletions

File tree

mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@
228228
},
229229
"enable-if": "show-sent && enable-sent-cache"
230230
},
231-
"senddb-api-url": {
232-
"name": "SendDB API URL",
231+
"custom-sends-endpoint": {
232+
"name": "Custom Sends Endpoint",
233233
"description": "Only modify this if you're on a GDPS and host a custom SendDB instance (or something with a similar API response)",
234234
"type": "string",
235235
"filter": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:/.-_%?&=[]@",
236-
"default": "https://api.senddb.dev/api/v1/level/"
236+
"default": ""
237237
},
238238
"disable-gdps-warning": {
239239
"name": "Disable GDPS Warning",

src/hooks/LevelInfoLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class $modify(MyLevelInfoLayer, LevelInfoLayer) {
181181
labelContent << "Has LDM: " << (level->m_lowDetailMode ? "Yes" : "No")
182182
<< std::endl;
183183

184-
if (SettingsManager::Toggles.sent && (!Utils::IsGDPS() || SettingsManager::Other.sendDbApiUrl != "https://api.senddb.dev/api/v1/level/")) {
184+
if (SettingsManager::Toggles.sent && (!Utils::IsGDPS() || !SettingsManager::Other.customSendsEndpoint.empty()) {
185185
if (level->m_stars == 0) {
186186
if (auto cached = SettingsManager::Other.enableSentCache ? SentCacheManager::GetLevel(level->m_levelID) : std::nullopt) {
187187
labelContent << "Sent: " << (cached.value() ? "Yes" : "No")

src/managers/SettingsManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ CustomStruct::ToggleSettings SettingsManager::Toggles = {
3636
CustomStruct::OtherSettings SettingsManager::Other = {
3737
Mod::get()->getSettingValue<bool>("enable-sent-cache"),
3838
Mod::get()->getSettingValue<int>("sent-cache-limit"),
39-
Mod::get()->getSettingValue<int>("sent-cache-expiration") * 60
39+
Mod::get()->getSettingValue<int>("sent-cache-expiration") * 60,
40+
Mod::get()->getSettingValue<std::string>("custom-sends-endpoint"),
41+
!Mod::get()->getSettingValue<bool>("disable-gdps-warning")
4042
};
4143

4244
// There is DEFINITELY a better way to do this but if it works it works
@@ -132,8 +134,8 @@ CustomStruct::OtherSettings SettingsManager::Other = {
132134
listenForSettingChanges<int>("sent-cache-expiration", [](int expiration) {
133135
SettingsManager::Other.maxSentCacheExpiration = expiration * 60;
134136
});
135-
listenForSettingChanges<std::string>("senddb-api-url", [](std::string url) {
136-
SettingsManager::Other.sendDbApiUrl = url;
137+
listenForSettingChanges<std::string>("custom-sends-endpoint", [](std::string url) {
138+
SettingsManager::Other.customSendsEndpoint = url;
137139
});
138140
listenForSettingChanges<bool>("disable-gdps-warning", [](bool enabled) {
139141
SettingsManager::Other.showGDPSWarning = !enabled;

src/utils/CustomStruct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace CustomStruct {
4949
bool enableSentCache;
5050
int maxSentCacheLimit;
5151
int maxSentCacheExpiration;
52-
std::string sendDbApiUrl;
52+
std::string customSendsEndpoint;
5353
bool showGDPSWarning;
5454
};
5555

src/utils/Utils.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ std::string const& Utils::RequestUserAgent = "LevelInfo/" + Mod::get()->getVersi
88
std::chrono::seconds const Utils::RequestTimeout = std::chrono::seconds(3);
99

1010
arc::Future<Result<bool, void>> Utils::CheckIfLevelSent(int levelID) {
11-
if (!Utils::IsGDPS() && SettingsManager::Other.sendDbApiUrl == "https://api.senddb.dev/api/v1/level/") {
11+
if (!Utils::IsGDPS() && SettingsManager::Other.customSendsEndpoint.empty()) {
1212
auto req = co_await utils::web::WebRequest()
1313
.userAgent(Utils::RequestUserAgent)
1414
.timeout(Utils::RequestTimeout)
@@ -17,7 +17,7 @@ arc::Future<Result<bool, void>> Utils::CheckIfLevelSent(int levelID) {
1717
auto body = req.json().unwrapOrDefault();
1818
auto error = body["error"].asString().unwrapOrDefault();
1919

20-
if (req.ok() && body.size() > 0 && error.size() <= 0)
20+
if (req.ok() && body.size() > 0 && error.empty())
2121
co_return Ok(body["sent"].asBool().unwrap());
2222
else
2323
log::warn(
@@ -29,7 +29,10 @@ arc::Future<Result<bool, void>> Utils::CheckIfLevelSent(int levelID) {
2929
auto req = co_await utils::web::WebRequest()
3030
.userAgent(Utils::RequestUserAgent)
3131
.timeout(Utils::RequestTimeout)
32-
.get(SettingsManager::Other.sendDbApiUrl + std::to_string(levelID));
32+
.get(SettingsManager::Other.customSendsEndpoint.empty()
33+
? "https://api.senddb.dev/api/v1/level/"
34+
: SettingsManager::Other.customSendsEndpoint
35+
+ std::to_string(levelID));
3336

3437
auto body = req.json().unwrapOrDefault();
3538

0 commit comments

Comments
 (0)