making WEB

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 00:45:17 +03:00
1 parent d146f11f02
commit 5c036d91fb
72 files changed
+5875 -1243

No files matched your search

+70 -1
View File
@@ -2,9 +2,13 @@
#include "CommandManager.hpp"
#include "ConfigLoader.hpp"
#include "LyricsService.hpp"
#include "MusicManager.hpp"
#include "NetworkClient.hpp"
#include "RpcServer.hpp"
#ifdef ECHOION_WITH_WEB
#include "echoion/web/HttpServer.hpp"
#endif
#include <ConfigManager.hpp>
#include <ConfigTypes.hpp>
#include <CoreInterface.hpp>
@@ -16,9 +20,13 @@
#include <Types.hpp>
#include <Void/Service/Registry.hpp>
#include <atomic>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <unordered_set>
#include <utility>
namespace Void::Logging
{
@@ -154,10 +162,24 @@ namespace Echoion::Core
void onMusicEvent(const Api::PluginEvent& event);
void broadcastEvent(const Api::PluginEvent& event);
[[nodiscard]] bool isAdmin(uint64_t clientId) const;
[[nodiscard]] bool isDj(uint64_t clientId) const;
void updateWhisperList();
void setupRpcHandlers();
void setupEventBusSubscriptions() noexcept;
// Fetch an online client's avatar bytes (TS local cache, then the
// myTeamSpeak URL, then a legacy file-transfer download) and persist
// them — and the myTS URL — to the database keyed by uid. Returns
// {contentType, bytes} on success. Web-agnostic; used by both the
// avatar HTTP provider and the background warmer.
[[nodiscard]] std::optional<std::pair<std::string, std::string>>
fetchClientAvatarBytes(const std::string& uid,
uint64_t clientId);
// Periodically cache avatars for every online client so they remain
// available (from the DB) once the user goes offline. Runs on
// avatarWarmer_.
void warmAvatarCache();
// Build the console + split-file logging stack and install it as
// the global Void::Log sink (logSink_ must outlive logging).
void installLogging();
@@ -167,6 +189,7 @@ namespace Echoion::Core
// Components
std::shared_ptr<NetworkClient> networkClient_;
std::shared_ptr<LyricsService> lyricsService_;
std::shared_ptr<MusicManager> musicManager_;
std::unique_ptr<CommandManager> commandManager_;
Api::PluginInterfacePtr pluginInterface_;
@@ -176,21 +199,67 @@ namespace Echoion::Core
std::filesystem::path configPath_;
std::chrono::system_clock::time_point startTime_;
std::atomic<bool> initialized_{false};
// Guards triggerAutoConnect() against duplicate connection
// attempts (reset on a failed initiation so a retry can run).
std::atomic<bool> autoConnectInitiated_{false};
// Event callbacks
std::vector<Api::EventCallback> eventCallbacks_;
mutable std::mutex eventMutex_;
// Admin tracking
// Admin / DJ tracking (RPC clients whose TeamSpeak identity is in
// a configured teamspeak.adminGroups / djGroups server group).
std::vector<uint64_t> adminClients_;
std::vector<uint64_t> djClients_;
mutable std::mutex adminMutex_;
// Authenticated RPC client -> stable TS uid + nickname, resolved
// at token auth. Keys per-user features (favorites, vote-skip).
struct RpcIdentity {
std::string uid;
std::string nickname;
};
std::map<uint64_t, RpcIdentity> rpcIdentities_;
mutable std::mutex rpcIdentityMutex_;
[[nodiscard]] std::optional<RpcIdentity>
rpcIdentity(uint64_t clientId) const;
// Full identity behind an RPC token: uid, display nickname and
// admin standing. Shared by token auth, IP autologin and the
// watch-together identity resolver.
struct TokenIdentity {
std::string uid;
std::string nickname;
bool isAdmin = false;
bool isDj = false;
};
[[nodiscard]] std::optional<TokenIdentity>
identityForToken(const std::string& token);
// Mark an RPC connection authenticated as `identity` (auth set,
// admin list, per-client identity map).
void registerRpcAuth(uint64_t clientId,
const TokenIdentity& identity);
// Guards RestartWebInterface against overlapping restarts.
std::atomic<bool> webRestartPending_{false};
// Database for persistence
std::shared_ptr<Api::Database> database_;
// Background avatar cache warmer + the uids already cached this
// session (so we don't re-download an unchanged avatar every cycle).
std::jthread avatarWarmer_;
std::unordered_set<std::string> warmedUids_;
// RPC server for Desktop/API clients
std::shared_ptr<RpcServer> rpcServer_;
#ifdef ECHOION_WITH_WEB
// Browser web interface: serves the static UI and hosts the
// independent sync-watch WebSocket. Bot control from the browser
// goes straight to the RPC server, so this holds no bot handles.
std::shared_ptr<Web::HttpServer> webServer_;
#endif
// Composition root: a type-keyed registry of all Core services
// (logger, config, event bus, network, database, music, rpc).
// initialize() provides each instance; resolveServices() and other