Compare commits
3
Commits
e7573fbcd0
...
caac928923
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caac928923 | ||
|
|
24075fbd52 | ||
|
|
295542ab9e |
No files matched your search
+8
-4
@@ -72,7 +72,11 @@ target_include_directories(EchoionApiPlugin INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/echoion/api/plugin>
|
||||
$<INSTALL_INTERFACE:include/echoion/api/plugin>
|
||||
)
|
||||
target_link_libraries(EchoionApiPlugin INTERFACE Echoion::ApiBase)
|
||||
target_link_libraries(EchoionApiPlugin INTERFACE
|
||||
Echoion::ApiBase
|
||||
Echoion::ApiTrack
|
||||
Void::Plugin
|
||||
)
|
||||
|
||||
# 6. Config Types (depends on Network, Audio)
|
||||
add_library(EchoionApiConfig INTERFACE)
|
||||
@@ -163,7 +167,7 @@ target_include_directories(EchoionApiOpaque INTERFACE
|
||||
)
|
||||
target_link_libraries(EchoionApiOpaque INTERFACE Echoion::ApiBase)
|
||||
|
||||
# 12a. PluginInterface only (minimal - for Plugin to implement)
|
||||
# 12a. Host interface used by Core and EchoionStandalone
|
||||
add_library(EchoionApiPluginInterface INTERFACE)
|
||||
add_library(Echoion::ApiPluginInterface ALIAS EchoionApiPluginInterface)
|
||||
target_include_directories(EchoionApiPluginInterface INTERFACE
|
||||
@@ -180,7 +184,7 @@ target_link_libraries(EchoionApiPluginInterface INTERFACE
|
||||
Echoion::ApiOpaque
|
||||
)
|
||||
|
||||
# 12b. CoreInterface (decoupled - for Plugin to call Core)
|
||||
# 12b. CoreInterface (decoupled host boundary)
|
||||
add_library(EchoionApiCoreInterface INTERFACE)
|
||||
add_library(Echoion::ApiCoreInterface ALIAS EchoionApiCoreInterface)
|
||||
target_include_directories(EchoionApiCoreInterface INTERFACE
|
||||
@@ -194,7 +198,7 @@ target_link_libraries(EchoionApiCoreInterface INTERFACE
|
||||
Echoion::ApiOpaque
|
||||
)
|
||||
|
||||
# 12c. Legacy Interfaces (both)
|
||||
# 12c. Combined host interfaces
|
||||
add_library(EchoionApiInterfaces INTERFACE)
|
||||
add_library(Echoion::ApiInterfaces ALIAS EchoionApiInterfaces)
|
||||
target_link_libraries(EchoionApiInterfaces INTERFACE
|
||||
|
||||
+5
-4
@@ -69,7 +69,7 @@ EchoionApi/include/echoion/api/
|
||||
|
||||
## Include Path Changes
|
||||
|
||||
### For Plugin (minimal):
|
||||
### For a host adapter (minimal):
|
||||
|
||||
**Before:**
|
||||
```cpp
|
||||
@@ -83,7 +83,8 @@ EchoionApi/include/echoion/api/
|
||||
#include <CoreInterface.hpp>
|
||||
```
|
||||
|
||||
The CMake target `Echoion::ApiPlugin` will add the correct include paths.
|
||||
The CMake target `Echoion::ApiPlugin` provides the event and host DTO include
|
||||
paths retained for source compatibility.
|
||||
|
||||
### For Core:
|
||||
|
||||
@@ -101,9 +102,9 @@ The CMake target `Echoion::ApiEventBus` adds `eventbus/` to the include path.
|
||||
|
||||
## CMake Usage
|
||||
|
||||
### Plugin only needs:
|
||||
### Standalone host needs:
|
||||
```cmake
|
||||
target_link_libraries(EchoionPlugin PRIVATE
|
||||
target_link_libraries(EchoionStandalone PRIVATE
|
||||
Echoion::ApiBase
|
||||
Echoion::ApiPlugin
|
||||
Echoion::ApiInterfaces
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "api/network/NetworkInterface.hpp"
|
||||
#include "api/network/NetworkTypes.hpp"
|
||||
#include "api/plugin/PluginTypes.hpp"
|
||||
#include "api/plugin/ExtensionPlugin.hpp"
|
||||
#include "api/rpc/RpcTypes.hpp"
|
||||
#include "api/track/TrackTypes.hpp"
|
||||
#include "api/youtube/YouTubeTypes.hpp"
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace Echoion::Api
|
||||
|
||||
// Version constants
|
||||
inline constexpr uint32_t VERSION_MAJOR = 1;
|
||||
inline constexpr uint32_t VERSION_MINOR = 0;
|
||||
inline constexpr uint32_t VERSION_MINOR = 1;
|
||||
inline constexpr uint32_t VERSION_PATCH = 0;
|
||||
inline constexpr const char* VERSION_STRING = "1.0.0";
|
||||
inline constexpr const char* VERSION_STRING = "1.1.0";
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef PLUGIN
|
||||
#include "ConfigTypes.hpp"
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
@@ -93,5 +92,3 @@ namespace Echoion::Api
|
||||
};
|
||||
|
||||
} // namespace Echoion::Api
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef PLUGIN
|
||||
#include "AudioTypes.hpp"
|
||||
#include "NetworkTypes.hpp"
|
||||
#include "Types.hpp"
|
||||
@@ -29,8 +28,8 @@ namespace Echoion::Api
|
||||
struct BotConfig {
|
||||
std::string botName = "Echoion";
|
||||
std::string commandPrefix = "!";
|
||||
// Default bot language ("en" or "ru"). Applies to users who have not
|
||||
// picked a per-user language. Anything else normalises to "en".
|
||||
// Default bot language ("en" or "ru"). Applies to users who have
|
||||
// not picked a per-user language. Anything else normalises to "en".
|
||||
std::string language = "en";
|
||||
float defaultVolume = 0.5f;
|
||||
uint32_t maxQueueSize = 100;
|
||||
@@ -61,9 +60,9 @@ namespace Echoion::Api
|
||||
std::string rpcBindAddress = "127.0.0.1";
|
||||
};
|
||||
|
||||
// Browser web interface (EchoionWeb). Serves the static UI and hosts the
|
||||
// independent sync-watch WebSocket. Bot control from the browser goes
|
||||
// directly to the RPC server (network.rpcPort), not through this server.
|
||||
// Browser web interface (EchoionWeb). Serves the public dashboard and
|
||||
// same-origin RPC bridge. Watch Together is deployed independently and
|
||||
// linked through watchUrl.
|
||||
struct WebConfig {
|
||||
bool enabled = false;
|
||||
uint16_t port = 8080;
|
||||
@@ -73,22 +72,41 @@ namespace Echoion::Api
|
||||
// UI derives ws://<page-host>:<rpcPort> from the served config.
|
||||
std::string rpcUrl;
|
||||
// Public address users reach the web interface at (e.g.
|
||||
// "https://bot.example.com"). Presentation only — !help links to
|
||||
// it when set; serving is unaffected.
|
||||
// "https://bot.example.com"). Required by the internal URL
|
||||
// shortener and also used by !help when set; serving is unaffected.
|
||||
std::string publicUrl;
|
||||
// External VoidWatch deployment. Echoion only presents this link
|
||||
// and redirects the retired local /watch entrypoint to it.
|
||||
std::string watchUrl;
|
||||
// Allow the Now Playing view to show the current song's video
|
||||
// (muted, synced). Users can still disable it locally; this is
|
||||
// the server-wide off switch, surfaced through /config.json.
|
||||
bool nowPlayingVideo = true;
|
||||
// Forwarded client addresses are trusted only when the immediate
|
||||
// peer belongs to one of these IPv4/IPv6 CIDRs. Empty is safest and
|
||||
// ignores X-Forwarded-For entirely.
|
||||
std::vector<std::string> trustedProxyCidrs;
|
||||
};
|
||||
|
||||
struct UrlShorteningConfig {
|
||||
bool enabled = false;
|
||||
std::string provider = "url-shortener-internal";
|
||||
std::vector<std::string> sources = {"youtube"};
|
||||
std::chrono::milliseconds timeout = std::chrono::milliseconds(3000);
|
||||
};
|
||||
|
||||
struct PluginsConfig {
|
||||
// Empty resolves to a plugins.d directory beside the main config.
|
||||
std::string configDirectory;
|
||||
};
|
||||
|
||||
// Music source resolution chain. Default order tries the native
|
||||
// innertube YouTube path and Yandex Music first, then falls back to
|
||||
// (optionally proxied) yt-dlp last.
|
||||
struct SourcesConfig {
|
||||
std::vector<std::string> order = {
|
||||
"innertube", "yandex", "direct-url",
|
||||
"ytdlp-direct", "ytdlp-proxied"};
|
||||
std::vector<std::string> order = {"innertube", "yandex",
|
||||
"direct-url", "ytdlp-direct",
|
||||
"ytdlp-proxied"};
|
||||
// How long a failing source is skipped before being retried.
|
||||
std::chrono::milliseconds failureCooldown =
|
||||
std::chrono::milliseconds(300000); // 5m
|
||||
@@ -132,9 +150,9 @@ namespace Echoion::Api
|
||||
std::chrono::milliseconds(3600000);
|
||||
bool enableAuditLog = true;
|
||||
std::optional<std::string> apiKey;
|
||||
// Reserved, not currently honored: the web UI, /rpc bridge and /ws
|
||||
// are all same-origin behind the web server, so no CORS headers are
|
||||
// emitted anywhere.
|
||||
// Reserved, not currently honored: the web UI and /rpc bridge are
|
||||
// same-origin behind the web server, so no CORS headers are
|
||||
// emitted.
|
||||
bool allowCors = false;
|
||||
std::vector<std::string> corsOrigins;
|
||||
};
|
||||
@@ -175,11 +193,76 @@ namespace Echoion::Api
|
||||
// across plays and restarts).
|
||||
bool cacheEnabled = true;
|
||||
std::string cacheMaxSize = "1GB";
|
||||
uint32_t cacheTTL = 86400; // seconds
|
||||
uint32_t cacheTTL = 86400; // seconds
|
||||
uint32_t tempCleanupInterval = 3600; // seconds
|
||||
};
|
||||
|
||||
// ServerConfig for Plugin interface (mirrors PluginTypes.hpp version)
|
||||
// Component updater. Runtime means the complete relocatable daemon bundle,
|
||||
// not only the echoiond ELF. Core and managed extension plugins may use
|
||||
// independent channels, but the updater still enforces the compatibility
|
||||
// metadata carried by the selected feed releases.
|
||||
struct UpdatePublicKey {
|
||||
std::string id;
|
||||
std::string ed25519;
|
||||
};
|
||||
|
||||
struct UpdateSourceConfig {
|
||||
// Empty is only meaningful for the built-in "official" source and
|
||||
// resolves to the URL injected by the release build.
|
||||
std::string url;
|
||||
std::vector<UpdatePublicKey> publicKeys;
|
||||
bool allowUnsigned = false;
|
||||
// Environment variable name only. Secret values are never
|
||||
// persisted.
|
||||
std::string bearerTokenEnv;
|
||||
};
|
||||
|
||||
struct UpdateComponentConfig {
|
||||
bool enabled = true;
|
||||
std::string source = "official";
|
||||
std::string channel = "stable";
|
||||
bool autoApply = true;
|
||||
};
|
||||
|
||||
struct PluginUpdateOverride {
|
||||
std::string source = "official";
|
||||
std::string channel = "stable";
|
||||
bool autoApply = true;
|
||||
};
|
||||
|
||||
struct PluginUpdatesConfig {
|
||||
bool enabled = true;
|
||||
std::string source = "official";
|
||||
std::string channel = "stable";
|
||||
bool autoApply = true;
|
||||
bool managedOnly = true;
|
||||
std::map<std::string, PluginUpdateOverride> overrides;
|
||||
};
|
||||
|
||||
struct UpdateMaintenanceWindow {
|
||||
// HH:MM in UTC. The updater validates the value before saving it.
|
||||
std::string start = "03:00";
|
||||
std::chrono::milliseconds duration = std::chrono::hours(2);
|
||||
};
|
||||
|
||||
struct UpdatesConfig {
|
||||
bool enabled = true;
|
||||
std::chrono::milliseconds checkInterval = std::chrono::hours(6);
|
||||
std::chrono::milliseconds jitter = std::chrono::minutes(30);
|
||||
UpdateMaintenanceWindow maintenanceWindowUtc;
|
||||
std::chrono::milliseconds maxRuntimeDeferral =
|
||||
std::chrono::hours(24);
|
||||
// Number of previous healthy versions retained in addition to
|
||||
// active.
|
||||
uint32_t retainHealthyVersions = 2;
|
||||
std::map<std::string, UpdateSourceConfig> sources = {
|
||||
{"official", UpdateSourceConfig{}}};
|
||||
UpdateComponentConfig runtime;
|
||||
UpdateComponentConfig core;
|
||||
PluginUpdatesConfig plugins;
|
||||
};
|
||||
|
||||
// Connection settings passed across the Echoion host interface.
|
||||
struct ServerConfig {
|
||||
std::string address;
|
||||
uint16_t port = 0;
|
||||
@@ -211,10 +294,12 @@ namespace Echoion::Api
|
||||
SecurityConfig security;
|
||||
FeaturesConfig features;
|
||||
AdvancedConfig advanced;
|
||||
UpdatesConfig updates;
|
||||
UrlShorteningConfig urlShortening;
|
||||
PluginsConfig plugins;
|
||||
AdminCredentials admin;
|
||||
WebConfig web;
|
||||
std::map<std::string, ConfigEntry> custom;
|
||||
};
|
||||
|
||||
} // namespace Echoion::Api
|
||||
#endif
|
||||
@@ -229,31 +229,11 @@ namespace Echoion::Api
|
||||
Api::Result<void> setKv(const std::string& key,
|
||||
const std::string& value);
|
||||
|
||||
// ===== Custom emojis (web UI image emotes) =====
|
||||
// Admin-managed image emotes referenced by :name: shortcodes in
|
||||
// watch chat/reactions. `data` is base64-encoded image bytes.
|
||||
struct CustomEmoji {
|
||||
std::string name;
|
||||
std::string mime;
|
||||
std::string dataBase64;
|
||||
std::string addedBy;
|
||||
};
|
||||
[[nodiscard]] Api::Result<std::vector<CustomEmoji>>
|
||||
getCustomEmojis();
|
||||
// Image (mime + base64 data) for one emoji name, or nullopt.
|
||||
[[nodiscard]] Api::Result<std::optional<CustomEmoji>>
|
||||
getCustomEmoji(const std::string& name);
|
||||
Api::Result<void> addCustomEmoji(const std::string& name,
|
||||
const std::string& mime,
|
||||
const std::string& dataBase64,
|
||||
const std::string& addedBy);
|
||||
Api::Result<void> removeCustomEmoji(const std::string& name);
|
||||
|
||||
// ===== Cached avatars (web UI) =====
|
||||
// TeamSpeak avatar images persisted by uid so the web UI can show
|
||||
// them even when the client is offline or out of the bot's view
|
||||
// (the live TS avatar cache only holds in-view clients). `data` is
|
||||
// base64-encoded image bytes, like custom emojis.
|
||||
// base64-encoded image bytes.
|
||||
struct CachedAvatar {
|
||||
std::string uid;
|
||||
std::string mime;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Echoion::Api
|
||||
struct QueueEntry;
|
||||
struct PlaylistInfo;
|
||||
|
||||
// Minimal PlaybackState for Plugin
|
||||
// Minimal playback state for the host boundary.
|
||||
struct PlaybackSummary {
|
||||
std::optional<TrackSummary> currentTrack;
|
||||
bool isPlaying = false;
|
||||
@@ -42,7 +42,7 @@ namespace Echoion::Api
|
||||
using CoreCreateFunc = std::function<CoreInterfacePtr()>;
|
||||
using CoreDestroyFunc = std::function<void(ICoreInterface*)>;
|
||||
|
||||
// Core interface that the Plugin will use to communicate with the Core
|
||||
// Core interface used by the standalone host to communicate with Core.
|
||||
// MINIMAL VERSION - breaks dependencies on Core-specific types
|
||||
class ICoreInterface
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace Echoion::Api
|
||||
virtual ~ICoreInterface() = default;
|
||||
|
||||
// Lifecycle
|
||||
// Plugin passes config file path, Core loads config internally
|
||||
// The host passes a config path; Core loads it internally.
|
||||
virtual Result<void>
|
||||
initialize(const std::filesystem::path& configPath) = 0;
|
||||
virtual Result<void> shutdown() = 0;
|
||||
@@ -158,6 +158,19 @@ namespace Echoion::Api
|
||||
// on the new Core (state-transfer corruption on hot reload). Only
|
||||
// ever add new virtuals at the very end.
|
||||
virtual Result<void> reloadConfig() = 0;
|
||||
|
||||
// Managed extension reconciliation for the host updater. The
|
||||
// request and response are versioned JSON documents so the plugin
|
||||
// package format can evolve without exposing Core implementation
|
||||
// types here. Append-only ABI: do not move this entry above
|
||||
// existing methods.
|
||||
[[nodiscard]] virtual Result<std::string>
|
||||
managePluginsJson(const std::string& /*requestJson*/)
|
||||
{
|
||||
return fail(
|
||||
ErrorCode::NotSupported,
|
||||
"managed plugin updates are not supported by this Core");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Echoion::Api
|
||||
@@ -71,7 +71,7 @@ namespace Echoion::Api
|
||||
// call returns the path). Downloads run asynchronously.
|
||||
[[nodiscard]] virtual Result<std::optional<std::string>>
|
||||
requestClientAvatar(uint64_t /*clientId*/,
|
||||
const std::string& /*destDir*/)
|
||||
const std::string& /*destDir*/)
|
||||
{
|
||||
return std::optional<std::string>{};
|
||||
}
|
||||
@@ -79,12 +79,92 @@ namespace Echoion::Api
|
||||
uint64_t channelId) = 0;
|
||||
virtual Result<void> kickClient(uint64_t clientId,
|
||||
const std::string& reason) = 0;
|
||||
virtual Result<void>
|
||||
kickClientFromChannel(uint64_t /*clientId*/,
|
||||
const std::string& /*reason*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"channel kick is not supported by this host");
|
||||
}
|
||||
virtual Result<void> banClient(uint64_t /*clientId*/,
|
||||
uint64_t /*durationSeconds*/,
|
||||
const std::string& /*reason*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"bans are not supported by this host");
|
||||
}
|
||||
[[nodiscard]] virtual Result<std::vector<BanInfo>> getBans()
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"ban listing is not supported by this host");
|
||||
}
|
||||
virtual Result<void> unban(uint64_t /*banId*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"unban is not supported by this host");
|
||||
}
|
||||
|
||||
// Channel operations
|
||||
[[nodiscard]] virtual Result<std::vector<ChannelInfo>>
|
||||
getChannels() const = 0;
|
||||
[[nodiscard]] virtual Result<std::optional<ChannelInfo>>
|
||||
getChannel(uint64_t channelId) const = 0;
|
||||
virtual Result<uint64_t>
|
||||
createChannel(const ChannelCreateOptions& /*options*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"channel creation is not supported by this host");
|
||||
}
|
||||
virtual Result<void>
|
||||
editChannel(uint64_t /*channelId*/,
|
||||
const ChannelEditOptions& /*options*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"channel editing is not supported by this host");
|
||||
}
|
||||
virtual Result<void> reorderChannel(uint64_t /*channelId*/,
|
||||
uint64_t /*parentId*/,
|
||||
uint64_t /*orderAfterId*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"channel reordering is not supported by this host");
|
||||
}
|
||||
virtual Result<void> deleteChannel(uint64_t /*channelId*/,
|
||||
bool /*force*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"channel deletion is not supported by this host");
|
||||
}
|
||||
|
||||
// Server-group administration. Membership changes use TeamSpeak's
|
||||
// stable client database id, not the connection-scoped client id.
|
||||
[[nodiscard]] virtual Result<std::vector<ServerGroupInfo>>
|
||||
getServerGroups()
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"server groups are not supported by this host");
|
||||
}
|
||||
virtual Result<void>
|
||||
addClientToServerGroup(uint64_t /*groupId*/,
|
||||
uint64_t /*clientDatabaseId*/)
|
||||
{
|
||||
return fail(
|
||||
ErrorCode::NotSupported,
|
||||
"server-group membership is not supported by this host");
|
||||
}
|
||||
virtual Result<void>
|
||||
removeClientFromServerGroup(uint64_t /*groupId*/,
|
||||
uint64_t /*clientDatabaseId*/)
|
||||
{
|
||||
return fail(
|
||||
ErrorCode::NotSupported,
|
||||
"server-group membership is not supported by this host");
|
||||
}
|
||||
[[nodiscard]] virtual Result<ServerInfo> getTeamSpeakServerInfo()
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"server information is not supported by this host");
|
||||
}
|
||||
|
||||
// Messaging
|
||||
virtual Result<void>
|
||||
@@ -115,6 +195,19 @@ namespace Echoion::Api
|
||||
registerEventCallback(const EventCallback& callback) = 0;
|
||||
virtual void
|
||||
unregisterEventCallback(const EventCallback& callback) = 0;
|
||||
|
||||
// Host-owned control plane. Keep this generic JSON operation at the
|
||||
// very end of the ABI so updater/service operations can evolve
|
||||
// without shifting existing vtable entries. Hosts that do not
|
||||
// expose a control plane retain the previous behavior through this
|
||||
// default.
|
||||
[[nodiscard]] virtual Result<std::string>
|
||||
hostControl(const std::string& /*method*/,
|
||||
const std::string& /*requestJson*/)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported,
|
||||
"host control is not supported by this host");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Echoion::Api
|
||||
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <PluginTypes.hpp>
|
||||
#include <TrackTypes.hpp>
|
||||
#include <Types.hpp>
|
||||
#include <Void/Plugin/Plugin.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Api
|
||||
{
|
||||
struct ExtensionCommand {
|
||||
std::string name;
|
||||
std::vector<std::string> aliases;
|
||||
std::string description;
|
||||
std::string usage;
|
||||
std::uint8_t category = 5;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionRpc {
|
||||
std::string name;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionMediaSource {
|
||||
std::string name;
|
||||
bool supportsSearch = false;
|
||||
};
|
||||
|
||||
struct ExtensionWebAsset {
|
||||
std::string id;
|
||||
std::string javascript;
|
||||
std::string css;
|
||||
};
|
||||
|
||||
struct ExtensionCommandRequest {
|
||||
std::string command;
|
||||
std::string arguments;
|
||||
std::uint64_t clientId = 0;
|
||||
std::string invokerName;
|
||||
};
|
||||
|
||||
struct ExtensionRpcRequest {
|
||||
std::string method;
|
||||
std::string params;
|
||||
std::uint64_t clientId = 0;
|
||||
};
|
||||
|
||||
struct ExtensionStream {
|
||||
std::string url;
|
||||
bool localFile = false;
|
||||
};
|
||||
|
||||
// Native, trusted Echoion extension contract. Calls are always made while
|
||||
// the host holds a Void::Plugin::PluginHandle, so a hot reload cannot
|
||||
// unmap code that is still executing.
|
||||
class IExtensionPlugin : public Void::Plugin::IPlugin
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] virtual std::vector<ExtensionCommand> commands() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionRpc> rpcMethods() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionMediaSource> mediaSources() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionWebAsset> webAssets() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual Result<std::string> executeCommand(
|
||||
const ExtensionCommandRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension command is not supported");
|
||||
}
|
||||
virtual Result<std::string> callRpc(const ExtensionRpcRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension RPC is not supported");
|
||||
}
|
||||
virtual void onEvent(const PluginEvent&) {}
|
||||
[[nodiscard]] virtual bool canHandleMedia(
|
||||
std::string_view, const std::string&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual Result<SearchResult> searchMedia(
|
||||
std::string_view, std::string_view)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension search is not supported");
|
||||
}
|
||||
virtual Result<TrackInfo> resolveMedia(
|
||||
std::string_view, const std::string&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension resolve is not supported");
|
||||
}
|
||||
virtual Result<ExtensionStream> streamMedia(
|
||||
std::string_view, const TrackInfo&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension stream is not supported");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef PLUGIN
|
||||
#include <ConfigTypes.hpp>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -41,10 +39,14 @@ namespace Echoion::Api
|
||||
ConfigurationChanged,
|
||||
// Appended: fired once the TeamSpeak connection is fully established
|
||||
// (client list available), so the core can resolve online subscribers.
|
||||
ConnectionEstablished
|
||||
ConnectionEstablished,
|
||||
// Appended for the authoritative TeamSpeak directory cache. Hosts may
|
||||
// emit either event after refreshing their local topology mirror.
|
||||
ClientUpdated,
|
||||
ChannelUpdated
|
||||
};
|
||||
|
||||
// Minimal track info for Plugin (no internal types)
|
||||
// Minimal track info for the host boundary (no internal types)
|
||||
struct TrackSummary {
|
||||
std::string id;
|
||||
std::string title;
|
||||
@@ -69,12 +71,15 @@ namespace Echoion::Api
|
||||
|
||||
struct ClientInfo {
|
||||
uint64_t id = 0;
|
||||
std::optional<uint64_t> databaseId;
|
||||
std::string nickname;
|
||||
std::optional<std::string> uniqueIdentifier;
|
||||
uint64_t channelId = 0;
|
||||
bool isTalking = false;
|
||||
bool isMuted = false;
|
||||
bool isDeafened = false;
|
||||
bool isAway = false;
|
||||
bool isQuery = false;
|
||||
std::vector<uint64_t> serverGroups;
|
||||
};
|
||||
|
||||
@@ -84,11 +89,48 @@ namespace Echoion::Api
|
||||
std::optional<uint64_t> parentId;
|
||||
uint64_t order = 0;
|
||||
bool isDefault = false;
|
||||
bool isPermanent = false;
|
||||
bool isSemiPermanent = false;
|
||||
bool hasPassword = false;
|
||||
uint32_t maxClients = 0;
|
||||
uint32_t currentClients = 0;
|
||||
};
|
||||
|
||||
struct ChannelCreateOptions {
|
||||
std::string name;
|
||||
std::optional<uint64_t> parentId;
|
||||
std::optional<uint64_t> orderAfterId;
|
||||
std::optional<std::string> topic;
|
||||
std::optional<std::string> description;
|
||||
std::optional<std::string> password;
|
||||
uint32_t maxClients = 0;
|
||||
bool permanent = true;
|
||||
};
|
||||
|
||||
struct ChannelEditOptions {
|
||||
std::optional<std::string> name;
|
||||
std::optional<std::string> topic;
|
||||
std::optional<std::string> description;
|
||||
std::optional<std::string> password;
|
||||
std::optional<uint32_t> maxClients;
|
||||
std::optional<bool> permanent;
|
||||
};
|
||||
|
||||
struct ServerGroupInfo {
|
||||
uint64_t id = 0;
|
||||
std::string name;
|
||||
bool isDefault = false;
|
||||
};
|
||||
|
||||
struct BanInfo {
|
||||
uint64_t id = 0;
|
||||
std::optional<std::string> uniqueIdentifier;
|
||||
std::optional<std::string> nickname;
|
||||
std::string reason;
|
||||
uint64_t createdAt = 0;
|
||||
uint64_t durationSeconds = 0; // 0 means permanent
|
||||
};
|
||||
|
||||
struct ServerInfo {
|
||||
uint64_t id = 0;
|
||||
std::string name;
|
||||
@@ -98,22 +140,6 @@ namespace Echoion::Api
|
||||
uint64_t defaultChannelId = 0;
|
||||
};
|
||||
|
||||
// ServerConfig is needed for Plugin's connectToServer()
|
||||
// This is a minimal version without dependencies on AudioTypes, etc.
|
||||
// Available to both Core and Plugin
|
||||
#ifdef PLUGIN
|
||||
struct ServerConfig {
|
||||
std::string address;
|
||||
uint16_t port = 0;
|
||||
std::string serverPassword;
|
||||
std::string nickname;
|
||||
std::optional<std::string> defaultChannelId;
|
||||
std::optional<std::string> channelPassword;
|
||||
std::vector<uint64_t> adminGroups;
|
||||
std::vector<uint64_t> djGroups;
|
||||
std::vector<uint64_t> bannedGroups;
|
||||
};
|
||||
#endif
|
||||
// ===== Callback Types =====
|
||||
|
||||
using EventCallback = std::function<void(const PluginEvent&)>;
|
||||
|
||||
@@ -68,15 +68,15 @@ namespace Echoion::Api
|
||||
|
||||
// Library (appended)
|
||||
GetPlaylist, // playlist contents by id
|
||||
GetHistory, // recently played tracks
|
||||
GetStats, // playback statistics
|
||||
GetHistory, // recently played tracks
|
||||
GetStats, // playback statistics
|
||||
|
||||
// Web UI (appended)
|
||||
GetFavorites, // authenticated user's favorites
|
||||
AddFavorite, // add a track to favorites
|
||||
RemoveFavorite, // remove by track url
|
||||
VoteSkip, // vote to skip the current track
|
||||
Announce, // admin: broadcast an announcement
|
||||
GetFavorites, // authenticated user's favorites
|
||||
AddFavorite, // add a track to favorites
|
||||
RemoveFavorite, // remove by track url
|
||||
VoteSkip, // vote to skip the current track
|
||||
Announce, // admin: broadcast an announcement
|
||||
GetAggregateStats, // server-wide dashboard statistics
|
||||
|
||||
// Web UI round 2 (appended)
|
||||
@@ -90,13 +90,43 @@ namespace Echoion::Api
|
||||
SetUserPrefs, // update per-user preferences; keys shared with the
|
||||
// chat commands (e.g. !lang) so both stay in sync
|
||||
|
||||
// Web UI round 4 (appended): custom emojis for watch chat/reactions
|
||||
GetCustomEmojis, // list custom emoji names (+ mime)
|
||||
AddCustomEmoji, // admin: add/replace a custom emoji (base64 image)
|
||||
RemoveCustomEmoji, // admin: delete a custom emoji
|
||||
|
||||
// Values 49-51 are reserved for retired browser features.
|
||||
// Web UI round 5 (appended): lyrics for the current track (lrclib)
|
||||
GetLyrics // plain + time-synced lyrics for the now-playing track
|
||||
GetLyrics = 52, // plain + time-synced lyrics for the now-playing track
|
||||
|
||||
// Values 53-66 belonged to the removed experimental TeamSpeak
|
||||
// listening-room API. Keep later values stable for stored audit rows.
|
||||
GetCapabilities = 67,
|
||||
GetPluginExtensions,
|
||||
PluginCall,
|
||||
|
||||
// Values 70-72 are reserved for retired browser features.
|
||||
// TeamSpeak directory and administration; 53-66 stay reserved.
|
||||
GetTeamSpeakDirectory = 73,
|
||||
MoveTeamSpeakClient,
|
||||
KickTeamSpeakClient,
|
||||
BanTeamSpeakClient,
|
||||
GetTeamSpeakBans,
|
||||
UnbanTeamSpeakClient,
|
||||
CreateTeamSpeakChannel,
|
||||
EditTeamSpeakChannel,
|
||||
ReorderTeamSpeakChannel,
|
||||
DeleteTeamSpeakChannel,
|
||||
GetTeamSpeakServerGroups,
|
||||
AddTeamSpeakServerGroupMember,
|
||||
RemoveTeamSpeakServerGroupMember,
|
||||
SendTeamSpeakPrivateMessage,
|
||||
SendTeamSpeakChannelMessage,
|
||||
SendTeamSpeakServerMessage,
|
||||
|
||||
// Component updater (append-only; values 89-95).
|
||||
GetUpdateStatus,
|
||||
GetUpdateConfig,
|
||||
SetUpdateConfig,
|
||||
CheckForUpdates,
|
||||
ApplyUpdate,
|
||||
RollbackUpdate,
|
||||
ConfirmUnsignedUpdate
|
||||
};
|
||||
|
||||
struct RpcRequest {
|
||||
|
||||
@@ -21,7 +21,10 @@ namespace Echoion::Api
|
||||
URL,
|
||||
// Appended after URL so existing uint8_t-serialized history rows
|
||||
// keep their meaning.
|
||||
Yandex
|
||||
Yandex,
|
||||
// Media returned by an extension plugin. Keep this distinct from
|
||||
// Unknown so source allowlists never have to permit unknown values.
|
||||
Plugin
|
||||
};
|
||||
|
||||
struct TrackInfo {
|
||||
@@ -34,15 +37,15 @@ namespace Echoion::Api
|
||||
TrackSource source;
|
||||
std::string originalUrl;
|
||||
std::optional<std::string>
|
||||
shortenedUrl; // faumaray.ru shortened link
|
||||
shortenedUrl; // provider-generated public link
|
||||
std::optional<std::string> streamUrl;
|
||||
std::optional<AudioStreamInfo> audioInfo;
|
||||
std::chrono::system_clock::time_point addedAt;
|
||||
std::string requestedBy;
|
||||
|
||||
// Format track as markdown link: [Title](shortenedUrl)
|
||||
// Only uses shortened URL (faumaray), returns empty string if not
|
||||
// available
|
||||
// Only uses a successfully generated shortened URL; returns no link
|
||||
// if unavailable.
|
||||
[[nodiscard]] std::string formatWithLink() const
|
||||
{
|
||||
if (shortenedUrl.has_value() && !shortenedUrl->empty()) {
|
||||
@@ -53,8 +56,8 @@ namespace Echoion::Api
|
||||
}
|
||||
|
||||
// Format track with artist and link
|
||||
// Only uses shortened URL (faumaray), returns text only if not
|
||||
// available
|
||||
// Only uses a successfully generated shortened URL; returns text if
|
||||
// unavailable.
|
||||
[[nodiscard]] std::string formatWithArtistAndLink() const
|
||||
{
|
||||
std::string displayTitle = title;
|
||||
|
||||
Reference in new issue
Block a user