#pragma once #include "Database.hpp" #include #include #include #include #include #include #include namespace Echoion::Core { /** * Manages user subscriptions to the bot's audio output * Subscriptions are persisted to database and survive client reloads * Uses unique client UID instead of session-specific client ID */ class SubscriptionManager { public: struct Subscriber { std::string uid; std::string nickname; }; SubscriptionManager(); ~SubscriptionManager(); // Initialize and load subscriptions from database Api::Result initialize(std::shared_ptr database); void shutdown(); // Subscription management (by UID) bool subscribe(const std::string& uid, const std::string& nickname); bool unsubscribe(const std::string& uid); bool isSubscribed(const std::string& uid) const; // Get all subscribed UIDs std::vector getSubscribedUids() const; // Get all subscribers with info std::vector getSubscribers() const; // Get subscriber nickname std::optional getSubscriberNickname(const std::string& uid) const; // Update nickname for subscriber bool updateNickname(const std::string& uid, const std::string& nickname); // Check if anyone is subscribed bool hasSubscribers() const; // Get subscriber count size_t getSubscriberCount() const; // Clear all subscriptions bool clearAll(); private: std::set subscribedUids_; mutable std::mutex mutex_; std::shared_ptr database_; bool initialized_ = false; }; } // namespace Echoion::Core