mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 20:47:10 +11:00
🐎 made getlogs endpoint cache result when disabled
This commit is contained in:
parent
3609291e31
commit
a78b4e5b1d
2 changed files with 26 additions and 24 deletions
|
|
@ -171,28 +171,21 @@ public:
|
|||
|
||||
Json::Value GetLogs(const std::string &name, const std::string &attempt)
|
||||
{
|
||||
if constexpr (max_log_size)
|
||||
Json::Value res;
|
||||
if (!users.if_contains(name, [&res, &attempt](const User &u) {
|
||||
if (u.password != XXH3_64bits(attempt.data(), attempt.size()))
|
||||
{
|
||||
res = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = u.log.Serialize();
|
||||
}
|
||||
}))
|
||||
{
|
||||
Json::Value res;
|
||||
if (!users.if_contains(name, [&res, &attempt](const User &u) {
|
||||
if (u.password != XXH3_64bits(attempt.data(), attempt.size()))
|
||||
{
|
||||
res = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = u.log.Serialize();
|
||||
}
|
||||
}))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "logs are disabled";
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void Save()
|
||||
|
|
@ -214,7 +207,7 @@ public:
|
|||
});
|
||||
}
|
||||
}
|
||||
if(!temp.isNull())
|
||||
if (!temp.isNull())
|
||||
{
|
||||
writer->write(temp, &user_save);
|
||||
}
|
||||
|
|
@ -232,7 +225,7 @@ public:
|
|||
JSONCPP_STRING errs;
|
||||
if (!parseFromStream(builder, user_save, &temp, &errs))
|
||||
{
|
||||
std::cerr<<errs<<'\n';
|
||||
std::cerr << errs << '\n';
|
||||
throw std::invalid_argument("Parsing Failed\n");
|
||||
user_save.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,17 @@ public:
|
|||
}
|
||||
void GetLog(req_args, const std::string &name)
|
||||
{
|
||||
GEN_BODY
|
||||
JSON(bank.GetLogs(name, body["attempt"].asCString()));
|
||||
if constexpr (max_log_size)
|
||||
{
|
||||
GEN_BODY
|
||||
JSON(bank.GetLogs(name, body["attempt"].asCString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto resp = HttpResponse::newHttpJsonResponse(JsonReturn("Logs are Disabled"));
|
||||
resp->setExpiredTime(0); //cached forever
|
||||
callback(resp);
|
||||
}
|
||||
}
|
||||
|
||||
METHOD_LIST_BEGIN
|
||||
|
|
|
|||
Loading…
Reference in a new issue