using HermesSocketLibrary.db; using ILogger = Serilog.ILogger; namespace HermesSocketServer.Requests { public class GetEnabledTTSVoices : IRequest { public string Name => "get_enabled_tts_voices"; public string[] RequiredKeys => []; private readonly Database _database; private readonly ILogger _logger; public GetEnabledTTSVoices(Database database, ILogger logger) { _database = database; _logger = logger; } public async Task Grant(string sender, IDictionary? data) { var temp = new Dictionary() { { "user", sender } }; var voices = new List(); string sql = $"SELECT v.name FROM \"TtsVoiceState\" s " + "INNER JOIN \"TtsVoice\" v ON s.\"ttsVoiceId\" = v.id " + "WHERE \"userId\" = @user AND state = true"; await _database.Execute(sql, temp, (r) => voices.Add(r.GetString(0))); _logger.Information($"Fetched all enabled TTS voice for channel [channel: {sender}]"); return RequestResult.Successful(voices, notifyClientsOnAccount: false); } } }