2024-06-24 18:21:59 -04:00
|
|
|
using HermesSocketLibrary.db;
|
|
|
|
using HermesSocketLibrary.Requests;
|
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetTTSUsers : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_tts_users";
|
|
|
|
private readonly Database _database;
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
public GetTTSUsers(Database database, ILogger logger)
|
|
|
|
{
|
|
|
|
_database = database;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-08-10 15:36:32 -04:00
|
|
|
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
2024-06-24 18:21:59 -04:00
|
|
|
{
|
2024-08-10 15:36:32 -04:00
|
|
|
var temp = new Dictionary<string, object>() { { "user", sender } };
|
2024-06-24 18:21:59 -04:00
|
|
|
|
|
|
|
IDictionary<long, string> users = new Dictionary<long, string>();
|
|
|
|
string sql = $"SELECT \"ttsVoiceId\", \"chatterId\" FROM \"TtsChatVoice\" WHERE \"userId\" = @user";
|
2024-08-10 15:36:32 -04:00
|
|
|
await _database.Execute(sql, temp, (r) => users.Add(r.GetInt64(1), r.GetString(0)));
|
|
|
|
_logger.Information($"Fetched all chatters' selected tts voice for channel [channel: {sender}]");
|
2024-06-24 18:21:59 -04:00
|
|
|
return new RequestResult(true, users, notifyClientsOnAccount: false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|