From a78b4e5b1d036412fdd1a935df76c96231f68435 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Thu, 3 Jun 2021 12:47:50 -0700 Subject: [PATCH] :racehorse: made getlogs endpoint cache result when disabled --- include/bank.hpp | 37 +++++++++++++++---------------------- include/bank_f.hpp | 13 +++++++++++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/bank.hpp b/include/bank.hpp index bf2bc9d..8b66c55 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -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<setExpiredTime(0); //cached forever + callback(resp); + } } METHOD_LIST_BEGIN