Skip to content

Commit c01ddae

Browse files
committed
glue: fix discourse identity crashes
1 parent 6808f9d commit c01ddae

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

code/components/glue/src/ConnectToNative.cpp

+19-12
Original file line numberDiff line numberDiff line change
@@ -446,22 +446,29 @@ static InitFunction initFunction([] ()
446446
}
447447
else if (!_wcsicmp(type, L"setDiscourseIdentity"))
448448
{
449-
auto json = nlohmann::json::parse(ToNarrow(arg));
449+
try
450+
{
451+
auto json = nlohmann::json::parse(ToNarrow(arg));
450452

451-
g_discourseUserToken = json.value<std::string>("token", "");
452-
g_discourseClientId = json.value<std::string>("clientId", "");
453+
g_discourseUserToken = json.value<std::string>("token", "");
454+
g_discourseClientId = json.value<std::string>("clientId", "");
453455

454-
Instance<::HttpClient>::Get()->DoPostRequest(
455-
"https://lambda.fivem.net/api/validate/discourse",
456+
Instance<::HttpClient>::Get()->DoPostRequest(
457+
"https://lambda.fivem.net/api/validate/discourse",
458+
{
459+
{ "entitlementId", ros::GetEntitlementSource() },
460+
{ "authToken", g_discourseUserToken },
461+
{ "clientId", g_discourseClientId },
462+
},
463+
[](bool, const char*, size_t)
456464
{
457-
{ "entitlementId", ros::GetEntitlementSource() },
458-
{ "authToken", g_discourseUserToken },
459-
{ "clientId", g_discourseClientId },
460-
},
461-
[](bool, const char*, size_t)
462-
{
463465

464-
});
466+
});
467+
}
468+
catch (const std::exception& e)
469+
{
470+
trace("failed to set discourse identity: %s\n", e.what());
471+
}
465472
}
466473
});
467474

0 commit comments

Comments
 (0)