add: open config if fail to connect to api

This commit is contained in:
Linventif 2024-03-31 15:51:07 +02:00
parent d2a86b2182
commit ded2ea4a6a
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24
3 changed files with 13 additions and 5 deletions

View File

@ -35,7 +35,8 @@ local netReceive = {
gmInte.showTestConnection(data) gmInte.showTestConnection(data)
end, end,
[5] = function(data) [5] = function(data)
gmInte.config = table.Merge(gmInte.config, data) gmInte.config = table.Merge(gmInte.config, data.config)
if (!data.other.aprovedCredentials) then RunConsoleCommand("gmod_integration_admin") end
end, end,
[6] = function(data) [6] = function(data)
gmInte.chatAddText(data) gmInte.chatAddText(data)

View File

@ -64,10 +64,16 @@ function gmInte.publicGetConfig(ply)
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
gmInte.SendNet("publicConfig", { gmInte.SendNet("publicConfig", {
["id"] = gmInte.config.id, ["config"] = {
["debug"] = gmInte.config.debug, ["id"] = gmInte.config.id,
["apiFQDN"] = gmInte.config.apiFQDN, ["debug"] = gmInte.config.debug,
["websocketFQDN"] = gmInte.config.websocketFQDN, ["apiFQDN"] = gmInte.config.apiFQDN,
["websocketFQDN"] = gmInte.config.websocketFQDN,
["version"] = gmInte.config.version,
},
["other"] = {
["aprovedCredentials"] = gmInte.aprovedCredentials,
}
}, ply) }, ply)
end end

View File

@ -79,6 +79,7 @@ function gmInte.http.requestAPI(params)
return failed(code, body) return failed(code, body)
end end
gmInte.aprovedCredentials = true
return success(code, body) return success(code, body)
end, end,
["failed"] = function(error) ["failed"] = function(error)