Format and .clang-format
This commit is contained in:
1 parent
6aed7b0027
commit
b94b634a87
47 files changed
+42341
-39711
No files matched your search
@@ -17,37 +17,40 @@ extern "C" {
|
||||
#include <libswresample/swresample.h>
|
||||
}
|
||||
enum class DecodeStatus { Idle, Processing, Completed, Failed, Cancelled };
|
||||
class AudioDecoder {
|
||||
public:
|
||||
struct AudioData {
|
||||
std::vector<short> buffer;
|
||||
int samples = 0;
|
||||
int channels = 0;
|
||||
int sampleRate = 0;
|
||||
};
|
||||
std::deque<std::vector<short>> m_chunkQueue;
|
||||
std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
std::atomic<bool> m_isDecodingFinished{false};
|
||||
AudioDecoder();
|
||||
~AudioDecoder();
|
||||
void StartDecode(const std::string &url, int targetSampleRate);
|
||||
void Cancel() { m_cancelRequested = true; }
|
||||
DecodeStatus GetStatus() const { return m_status; }
|
||||
AudioData GetResult() { return std::move(m_result); }
|
||||
bool GetNextChunk(std::vector<short> &outChunk, bool blocking = false);
|
||||
bool IsFinished() const { return m_finished.load(); }
|
||||
class AudioDecoder
|
||||
{
|
||||
public:
|
||||
|
||||
private:
|
||||
void Cleanup();
|
||||
void InternalDecode(std::string url, int targetSampleRate);
|
||||
std::atomic<DecodeStatus> m_status{DecodeStatus::Idle};
|
||||
std::atomic<bool> m_cancelRequested{false};
|
||||
std::jthread m_thread;
|
||||
std::mutex m_logMtx;
|
||||
AudioData m_result;
|
||||
std::atomic<bool> m_finished{false};
|
||||
AVFormatContext *m_formatCtx = nullptr;
|
||||
AVCodecContext *m_codecCtx = nullptr;
|
||||
SwrContext *m_swrCtx = nullptr;
|
||||
struct AudioData {
|
||||
std::vector<short> buffer;
|
||||
int samples = 0;
|
||||
int channels = 0;
|
||||
int sampleRate = 0;
|
||||
};
|
||||
std::deque<std::vector<short>> m_chunkQueue;
|
||||
std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
std::atomic<bool> m_isDecodingFinished{false};
|
||||
AudioDecoder();
|
||||
~AudioDecoder();
|
||||
void StartDecode(const std::string &url, int targetSampleRate);
|
||||
void Cancel() { m_cancelRequested = true; }
|
||||
DecodeStatus GetStatus() const { return m_status; }
|
||||
AudioData GetResult() { return std::move(m_result); }
|
||||
bool GetNextChunk(std::vector<short> &outChunk, bool blocking = false);
|
||||
bool IsFinished() const { return m_finished.load(); }
|
||||
|
||||
private:
|
||||
|
||||
void Cleanup();
|
||||
void InternalDecode(std::string url, int targetSampleRate);
|
||||
std::atomic<DecodeStatus> m_status{DecodeStatus::Idle};
|
||||
std::atomic<bool> m_cancelRequested{false};
|
||||
std::jthread m_thread;
|
||||
std::mutex m_logMtx;
|
||||
AudioData m_result;
|
||||
std::atomic<bool> m_finished{false};
|
||||
AVFormatContext *m_formatCtx = nullptr;
|
||||
AVCodecContext *m_codecCtx = nullptr;
|
||||
SwrContext *m_swrCtx = nullptr;
|
||||
};
|
||||
@@ -8,121 +8,119 @@
|
||||
|
||||
#include "Singleton.hpp"
|
||||
|
||||
namespace ts6bot {
|
||||
namespace ts6bot
|
||||
{
|
||||
|
||||
enum class LogLevel {
|
||||
Trace,
|
||||
Debug,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Critical,
|
||||
None
|
||||
};
|
||||
enum class LogLevel { Trace, Debug, Info, Warning, Error, Critical, None };
|
||||
|
||||
struct ServerQueryConfig {
|
||||
std::string host{"127.0.0.1"};
|
||||
uint16_t port{
|
||||
10022}; // ServerQuery SSH default :contentReference[oaicite:6]{index=6}
|
||||
std::string username{"serveradmin"};
|
||||
std::string password{};
|
||||
int virtual_server_id{1};
|
||||
std::string nickname{"ts6bot"};
|
||||
};
|
||||
struct ServerQueryConfig {
|
||||
std::string host{"127.0.0.1"};
|
||||
uint16_t port{10022}; // ServerQuery SSH default
|
||||
// :contentReference[oaicite:6]{index=6}
|
||||
std::string username{"serveradmin"};
|
||||
std::string password{};
|
||||
int virtual_server_id{1};
|
||||
std::string nickname{"ts6bot"};
|
||||
};
|
||||
|
||||
struct AfkConfig {
|
||||
bool enabled{true};
|
||||
int idle_seconds{600};
|
||||
std::uint64_t afk_channel_id{0};
|
||||
int poll_interval_ms{5000};
|
||||
};
|
||||
struct AfkConfig {
|
||||
bool enabled{true};
|
||||
int idle_seconds{600};
|
||||
std::uint64_t afk_channel_id{0};
|
||||
int poll_interval_ms{5000};
|
||||
};
|
||||
|
||||
struct MusicConfig {
|
||||
bool enabled{true};
|
||||
std::string youtubeApiToken;
|
||||
};
|
||||
struct MusicConfig {
|
||||
bool enabled{true};
|
||||
std::string youtubeApiToken;
|
||||
};
|
||||
|
||||
struct ProxyConfiguration : public ProxyConfig {
|
||||
bool enabled{false};
|
||||
};
|
||||
struct ProxyConfiguration : public ProxyConfig {
|
||||
bool enabled{false};
|
||||
};
|
||||
|
||||
struct Config {
|
||||
std::string nickname;
|
||||
std::string host;
|
||||
std::string channel;
|
||||
std::string password;
|
||||
LogLevel loggingLevel;
|
||||
AfkConfig afk{};
|
||||
MusicConfig music{};
|
||||
ProxyConfiguration proxy{};
|
||||
};
|
||||
struct Config {
|
||||
std::string nickname;
|
||||
std::string host;
|
||||
std::string channel;
|
||||
std::string password;
|
||||
LogLevel loggingLevel;
|
||||
AfkConfig afk{};
|
||||
MusicConfig music{};
|
||||
ProxyConfiguration proxy{};
|
||||
};
|
||||
|
||||
class Configuration : public Singleton<Configuration> {
|
||||
friend class Singleton<Configuration>;
|
||||
public:
|
||||
const Config getConfig() const noexcept { return m_config; }
|
||||
class Configuration : public Singleton<Configuration>
|
||||
{
|
||||
friend class Singleton<Configuration>;
|
||||
|
||||
Configuration(std::string path) {
|
||||
auto config = Config();
|
||||
std::string buffer;
|
||||
auto ec = glz::read_file_json(config, path, buffer);
|
||||
if (ec) {
|
||||
std::string descriptive_error = glz::format_error(ec, buffer);
|
||||
std::cerr << "Not found configuration in " << path << " using default"
|
||||
<< std::endl;
|
||||
std::cerr << descriptive_error << std::endl;
|
||||
std::cerr << ec.ec << std::endl;
|
||||
m_config = Config();
|
||||
}
|
||||
this->m_config = config;
|
||||
}
|
||||
public:
|
||||
|
||||
Config m_config{};
|
||||
};
|
||||
const Config getConfig() const noexcept { return m_config; }
|
||||
|
||||
// Glaze meta (explicit, stable)
|
||||
Configuration(std::string path)
|
||||
{
|
||||
auto config = Config();
|
||||
std::string buffer;
|
||||
auto ec = glz::read_file_json(config, path, buffer);
|
||||
if (ec) {
|
||||
std::string descriptive_error =
|
||||
glz::format_error(ec, buffer);
|
||||
std::cerr << "Not found configuration in " << path
|
||||
<< " using default" << std::endl;
|
||||
std::cerr << descriptive_error << std::endl;
|
||||
std::cerr << ec.ec << std::endl;
|
||||
m_config = Config();
|
||||
}
|
||||
this->m_config = config;
|
||||
}
|
||||
|
||||
Config m_config{};
|
||||
};
|
||||
|
||||
// Glaze meta (explicit, stable)
|
||||
|
||||
} // namespace ts6bot
|
||||
template <> struct glz::meta<ProxyType> {
|
||||
using enum ProxyType;
|
||||
static constexpr auto value = enumerate(HTTP, SOCKS5, SOCKS5_HOSTNAME);
|
||||
using enum ProxyType;
|
||||
static constexpr auto value = enumerate(HTTP, SOCKS5, SOCKS5_HOSTNAME);
|
||||
};
|
||||
template <> struct glz::meta<ts6bot::LogLevel> {
|
||||
using enum ts6bot::LogLevel;
|
||||
static constexpr auto value =
|
||||
enumerate(Critical, Error, Warning, Info, Trace);
|
||||
using enum ts6bot::LogLevel;
|
||||
static constexpr auto value =
|
||||
enumerate(Critical, Error, Warning, Info, Trace);
|
||||
};
|
||||
template <> struct glz::meta<ts6bot::ServerQueryConfig> {
|
||||
using T = ts6bot::ServerQueryConfig;
|
||||
static constexpr auto value =
|
||||
object("host", &T::host, "port", &T::port, "username", &T::username,
|
||||
"password", &T::password, "virtual_server_id",
|
||||
&T::virtual_server_id, "nickname", &T::nickname);
|
||||
using T = ts6bot::ServerQueryConfig;
|
||||
static constexpr auto value =
|
||||
object("host", &T::host, "port", &T::port, "username", &T::username,
|
||||
"password", &T::password, "virtual_server_id",
|
||||
&T::virtual_server_id, "nickname", &T::nickname);
|
||||
};
|
||||
|
||||
template <> struct glz::meta<ts6bot::AfkConfig> {
|
||||
using T = ts6bot::AfkConfig;
|
||||
static constexpr auto value =
|
||||
object("enabled", &T::enabled, "idle_seconds", &T::idle_seconds,
|
||||
"afk_channel_id", &T::afk_channel_id, "poll_interval_ms",
|
||||
&T::poll_interval_ms);
|
||||
using T = ts6bot::AfkConfig;
|
||||
static constexpr auto value =
|
||||
object("enabled", &T::enabled, "idle_seconds", &T::idle_seconds,
|
||||
"afk_channel_id", &T::afk_channel_id, "poll_interval_ms",
|
||||
&T::poll_interval_ms);
|
||||
};
|
||||
|
||||
template <> struct glz::meta<ts6bot::MusicConfig> {
|
||||
using T = ts6bot::MusicConfig;
|
||||
static constexpr auto value =
|
||||
object("enabled", &T::enabled, "youtubeApiToken", &T::youtubeApiToken);
|
||||
using T = ts6bot::MusicConfig;
|
||||
static constexpr auto value = object(
|
||||
"enabled", &T::enabled, "youtubeApiToken", &T::youtubeApiToken);
|
||||
};
|
||||
template <> struct glz::meta<ts6bot::ProxyConfiguration> {
|
||||
using T = ts6bot::ProxyConfiguration;
|
||||
static constexpr auto value =
|
||||
object("url", &T::url, "username", &T::username, "password", &T::password,
|
||||
"type", &T::type, "enabled", &T::enabled);
|
||||
using T = ts6bot::ProxyConfiguration;
|
||||
static constexpr auto value =
|
||||
object("url", &T::url, "username", &T::username, "password",
|
||||
&T::password, "type", &T::type, "enabled", &T::enabled);
|
||||
};
|
||||
template <> struct glz::meta<ts6bot::Config> {
|
||||
using T = ts6bot::Config;
|
||||
static constexpr auto value =
|
||||
object("nickname", &T::nickname, "host", &T::host, "channel", &T::channel,
|
||||
"password", &T::password, "loggingLevel", &T::loggingLevel, "afk",
|
||||
&T::afk, "music", &T::music, "proxy", &T::proxy);
|
||||
using T = ts6bot::Config;
|
||||
static constexpr auto value = object(
|
||||
"nickname", &T::nickname, "host", &T::host, "channel", &T::channel,
|
||||
"password", &T::password, "loggingLevel", &T::loggingLevel, "afk",
|
||||
&T::afk, "music", &T::music, "proxy", &T::proxy);
|
||||
};
|
||||
@@ -6,18 +6,19 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ts6bot::crypto {
|
||||
namespace ts6bot::crypto
|
||||
{
|
||||
|
||||
// RFC 7636: length 43..128, chars [A-Z a-z 0-9 - . _ ~]
|
||||
std::string GenerateCodeVerifier(std::size_t length = 64);
|
||||
// RFC 7636: length 43..128, chars [A-Z a-z 0-9 - . _ ~]
|
||||
std::string GenerateCodeVerifier(std::size_t length = 64);
|
||||
|
||||
// Random state value (base64url, no padding).
|
||||
std::string GenerateState(std::size_t bytes = 16);
|
||||
// Random state value (base64url, no padding).
|
||||
std::string GenerateState(std::size_t bytes = 16);
|
||||
|
||||
std::vector<std::uint8_t> Sha256(std::span<const std::uint8_t> data);
|
||||
std::vector<std::uint8_t> Sha256(std::span<const char> data);
|
||||
std::vector<std::uint8_t> Sha256(std::span<const std::uint8_t> data);
|
||||
std::vector<std::uint8_t> Sha256(std::span<const char> data);
|
||||
|
||||
// Base64url encode without padding.
|
||||
std::string Base64UrlEncode(std::span<const std::uint8_t> data);
|
||||
// Base64url encode without padding.
|
||||
std::string Base64UrlEncode(std::span<const std::uint8_t> data);
|
||||
|
||||
} // namespace ts6bot::crypto
|
||||
@@ -16,85 +16,105 @@
|
||||
#include <ts3_functions.h>
|
||||
#include <ts6bot/AudioDecoder.hpp>
|
||||
#include <vector>
|
||||
class MusicManager {
|
||||
public:
|
||||
explicit MusicManager(std::shared_ptr<TS3Functions> functions, std::uint64_t serverConnectionHandlerID = 0);
|
||||
~MusicManager();
|
||||
class MusicManager
|
||||
{
|
||||
public:
|
||||
|
||||
struct Music {
|
||||
std::string name;
|
||||
std::string shortUrl;
|
||||
std::string length;
|
||||
std::string videoId;
|
||||
std::string requestedBy;
|
||||
YouTube::Result<definitions::Streams> streams;
|
||||
};
|
||||
explicit MusicManager(std::shared_ptr<TS3Functions> functions,
|
||||
std::uint64_t serverConnectionHandlerID = 0);
|
||||
~MusicManager();
|
||||
|
||||
// Playback Control
|
||||
void stop();
|
||||
void skip();
|
||||
void forceSkip();
|
||||
void setStopAfterCurrent(bool val) { m_stopAfterCurrent = val; }
|
||||
bool isIdle() const { return m_isIdle; }
|
||||
std::uint64_t getServerConnectionHandlerID() const
|
||||
{return m_serverConnectionHandlerID; }
|
||||
void setServerConnectionHandlerID(std::uint64_t id) { m_serverConnectionHandlerID = id; }
|
||||
// Subscription (Whisper) Management
|
||||
void subscribe(anyID id);
|
||||
void moveSubscriberToOffline(anyID id);
|
||||
void moveSubscriberToOnline(anyID id);
|
||||
void addSubscriberToOnline(anyID id);
|
||||
void addSubscriberToOffline(anyID id);
|
||||
void unSubscribe(anyID id);
|
||||
std::set<uint64_t> getOnlineSubscribers() const;
|
||||
std::set<uint64_t> getOfflineSubscribers() const;
|
||||
// Queue Management
|
||||
std::vector<Music> getQueue() const;
|
||||
std::optional<Music> getCurrent() const { return m_current; }
|
||||
void removeFromQueue(std::size_t index);
|
||||
void removeFromQueue(const std::string &name);
|
||||
void addToQueueDirect(const std::string& vid, const std::string& title, const std::string& shortUrl, const std::string& length, const std::string& req, std::optional<definitions::Streams> streams);
|
||||
void checkQueueAndPlay();
|
||||
struct Music {
|
||||
std::string name;
|
||||
std::string shortUrl;
|
||||
std::string length;
|
||||
std::string videoId;
|
||||
std::string requestedBy;
|
||||
YouTube::Result<definitions::Streams> streams;
|
||||
};
|
||||
|
||||
// Youtube / Search
|
||||
std::vector<definitions::SearchResultItem> search(std::string name, int maxResults = 5) const;
|
||||
void playUrl(std::string url, const std::string &requester = "");
|
||||
void playPlaylist(const std::string& playlistId, const std::string& requester);
|
||||
// Helper to extract playlist ID from URL
|
||||
std::optional<std::string> extractPlaylistId(std::string_view url);
|
||||
// Selection Logic
|
||||
// Stores the results for a specific user to select later
|
||||
void storePendingSearch(anyID clientId,
|
||||
const std::vector<definitions::SearchResultItem> &results);
|
||||
bool selectSearchResult(anyID clientId, int index, const std::string& requesterName);
|
||||
// Playback Control
|
||||
void stop();
|
||||
void skip();
|
||||
void forceSkip();
|
||||
void setStopAfterCurrent(bool val) { m_stopAfterCurrent = val; }
|
||||
bool isIdle() const { return m_isIdle; }
|
||||
std::uint64_t getServerConnectionHandlerID() const
|
||||
{
|
||||
return m_serverConnectionHandlerID;
|
||||
}
|
||||
void setServerConnectionHandlerID(std::uint64_t id)
|
||||
{
|
||||
m_serverConnectionHandlerID = id;
|
||||
}
|
||||
// Subscription (Whisper) Management
|
||||
bool subscribe(anyID id);
|
||||
void moveSubscriberToOffline(anyID id);
|
||||
void moveSubscriberToOnline(anyID id);
|
||||
bool addSubscriberToOnline(anyID id);
|
||||
bool addSubscriberToOffline(anyID id);
|
||||
bool unSubscribe(anyID id);
|
||||
std::set<uint64_t> getOnlineSubscribers() const;
|
||||
std::set<uint64_t> getOfflineSubscribers() const;
|
||||
// Queue Management
|
||||
std::vector<Music> getQueue() const;
|
||||
std::optional<Music> getCurrent() const { return m_current; }
|
||||
void removeFromQueue(std::size_t index);
|
||||
void removeFromQueue(const std::string& name);
|
||||
void addToQueueDirect(const std::string& vid,
|
||||
const std::string& title,
|
||||
const std::string& shortUrl,
|
||||
const std::string& length,
|
||||
const std::string& req,
|
||||
std::optional<definitions::Streams>
|
||||
streams);
|
||||
void checkQueueAndPlay();
|
||||
|
||||
private:
|
||||
void loop(std::stop_token st);
|
||||
static std::string formatDuration(const std::string &isoDuration);
|
||||
void updateWhisperList();
|
||||
// Youtube / Search
|
||||
std::vector<definitions::SearchResultItem>
|
||||
search(std::string name, int maxResults = 5) const;
|
||||
bool playUrl(std::string url, const std::string& requester = "");
|
||||
bool playPlaylist(const std::string& playlistId,
|
||||
const std::string& requester);
|
||||
// Helper to extract playlist ID from URL
|
||||
std::optional<std::string> extractPlaylistId(std::string_view url);
|
||||
// Selection Logic
|
||||
// Stores the results for a specific user to select later
|
||||
void storePendingSearch(
|
||||
anyID clientId,
|
||||
const std::vector<definitions::SearchResultItem>& results);
|
||||
bool selectSearchResult(anyID clientId,
|
||||
int index,
|
||||
const std::string& requesterName);
|
||||
|
||||
std::shared_ptr<TS3Functions> m_functions{nullptr};
|
||||
std::unique_ptr<AudioDecoder> m_microphone{nullptr};
|
||||
std::unique_ptr<YouTube::Client> m_client{nullptr};
|
||||
private:
|
||||
|
||||
void loop(std::stop_token st);
|
||||
static std::string formatDuration(const std::string& isoDuration);
|
||||
void updateWhisperList();
|
||||
|
||||
std::atomic<bool> m_stopAfterCurrent{false};
|
||||
std::atomic<bool> m_isIdle{true};
|
||||
std::shared_ptr<TS3Functions> m_functions{nullptr};
|
||||
std::unique_ptr<AudioDecoder> m_microphone{nullptr};
|
||||
std::unique_ptr<YouTube::Client> m_client{nullptr};
|
||||
|
||||
std::deque<Music> m_queue{};
|
||||
mutable std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
std::atomic<bool> m_stopAfterCurrent{false};
|
||||
std::atomic<bool> m_isIdle{true};
|
||||
|
||||
std::set<anyID> m_onlineSubscribers;
|
||||
std::set<anyID> m_offlineSubscribers;
|
||||
// Playback Control
|
||||
std::atomic_bool m_skipRequested{false};
|
||||
std::deque<Music> m_queue{};
|
||||
mutable std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
|
||||
std::atomic<float> m_volume{0.5f}; // Default 50%
|
||||
std::uint64_t m_serverConnectionHandlerID = 0;
|
||||
std::optional<Music> m_current;
|
||||
std::mutex m_subMtx;
|
||||
std::map<anyID, std::vector<definitions::SearchResultItem>> m_pendingSearches;
|
||||
std::mutex m_pendingMtx;
|
||||
std::jthread m_worker;
|
||||
std::set<anyID> m_onlineSubscribers;
|
||||
std::set<anyID> m_offlineSubscribers;
|
||||
// Playback Control
|
||||
std::atomic_bool m_skipRequested{false};
|
||||
|
||||
std::atomic<float> m_volume{0.5f}; // Default 50%
|
||||
std::uint64_t m_serverConnectionHandlerID = 0;
|
||||
std::optional<Music> m_current;
|
||||
std::mutex m_subMtx;
|
||||
std::map<anyID, std::vector<definitions::SearchResultItem>>
|
||||
m_pendingSearches;
|
||||
std::mutex m_pendingMtx;
|
||||
std::jthread m_worker;
|
||||
};
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#include <string>
|
||||
enum class ProxyType {
|
||||
HTTP,
|
||||
SOCKS5,
|
||||
SOCKS5_HOSTNAME // Use this to let the proxy resolve the DNS
|
||||
HTTP,
|
||||
SOCKS5,
|
||||
SOCKS5_HOSTNAME // Use this to let the proxy resolve the DNS
|
||||
};
|
||||
struct ProxyConfig {
|
||||
std::string url;
|
||||
ProxyType type = ProxyType::SOCKS5_HOSTNAME;
|
||||
std::string username = "";
|
||||
std::string password = "";
|
||||
};
|
||||
std::string url;
|
||||
ProxyType type = ProxyType::SOCKS5_HOSTNAME;
|
||||
std::string username = "";
|
||||
std::string password = "";
|
||||
};
|
||||
+13
-12
@@ -3,20 +3,21 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace ts6bot::url {
|
||||
namespace ts6bot::url
|
||||
{
|
||||
|
||||
// Percent-encode a string for use as a query parameter value.
|
||||
std::string EncodeComponent(const std::string& s);
|
||||
// Percent-encode a string for use as a query parameter value.
|
||||
std::string EncodeComponent(const std::string& s);
|
||||
|
||||
struct HttpUrl {
|
||||
std::string host;
|
||||
uint16_t port{};
|
||||
std::string path; // begins with '/'
|
||||
};
|
||||
struct HttpUrl {
|
||||
std::string host;
|
||||
uint16_t port{};
|
||||
std::string path; // begins with '/'
|
||||
};
|
||||
|
||||
// Minimal parser for redirect URIs.
|
||||
// Supports: http://<host>:<port>/<path>
|
||||
// Throws std::runtime_error on invalid input.
|
||||
HttpUrl ParseHttpUrl(const std::string& httpUrl);
|
||||
// Minimal parser for redirect URIs.
|
||||
// Supports: http://<host>:<port>/<path>
|
||||
// Throws std::runtime_error on invalid input.
|
||||
HttpUrl ParseHttpUrl(const std::string& httpUrl);
|
||||
|
||||
} // namespace ts6bot::url
|
||||
Reference in new issue
Block a user