Swap hand-rolled utils for Void primitives
Replace bespoke implementations with the new universal Void utilities: - YouTubeClient: urlEncode -> Void::Encoding::Url::encode; ~140-line decodeHtmlEntities -> Void::Text::html_unescape; parseIso8601Duration -> Void::Time::parse_iso8601_interval. - StateSerializer: getCurrentTimestampISO8601 -> Void::Time::utc_now_iso8601. - Database: generateRpcToken's rand() loop -> Void::Random::random_string (seeded from std::random_device). Link Void::Text / Void::Time / Void::Math. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
d74a69aa34
commit
00759450ff
4 files changed
+18
-211
No files matched your search
+4
-8
@@ -1,5 +1,6 @@
|
||||
#include <Database.hpp>
|
||||
#include "echoion/core/Logger.hpp"
|
||||
#include <Void/Math/Random.hpp>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <shared_mutex>
|
||||
@@ -1026,14 +1027,9 @@ namespace Echoion::Api
|
||||
Error(ErrorCode::NotFound, "Subscriber not found"));
|
||||
}
|
||||
|
||||
// Generate a random token (32 characters)
|
||||
const char charset[] =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
std::string token;
|
||||
token.reserve(32);
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
token += charset[rand() % (sizeof(charset) - 1)];
|
||||
}
|
||||
// Generate a random 32-character alphanumeric token (Void::Random is
|
||||
// seeded from std::random_device, unlike the former rand()).
|
||||
const std::string token = Void::Random::random_string(32);
|
||||
|
||||
// Insert token
|
||||
const char* sql = R"(
|
||||
|
||||
Reference in new issue
Block a user