2024-08-10 15:36:32 -04:00
|
|
|
using HermesSocketLibrary.Requests;
|
2024-10-20 14:07:18 -04:00
|
|
|
using HermesSocketServer.Store;
|
2024-08-10 15:36:32 -04:00
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetDefaultTTSVoice : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_default_tts_voice";
|
2024-10-20 14:07:18 -04:00
|
|
|
private readonly UserStore _users;
|
|
|
|
private readonly ServerConfiguration _configuration;
|
|
|
|
private readonly ILogger _logger;
|
2024-08-10 15:36:32 -04:00
|
|
|
|
2024-10-20 14:07:18 -04:00
|
|
|
public GetDefaultTTSVoice(UserStore users, ServerConfiguration configuration, ILogger logger)
|
2024-08-10 15:36:32 -04:00
|
|
|
{
|
2024-10-20 14:07:18 -04:00
|
|
|
_users = users;
|
|
|
|
_configuration = configuration;
|
2024-08-10 15:36:32 -04:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
|
|
|
{
|
2024-10-20 14:07:18 -04:00
|
|
|
var user = _users.Get(sender);
|
|
|
|
if (user == null)
|
|
|
|
return new RequestResult(false, "Unable to find user data.", notifyClientsOnAccount: false);
|
|
|
|
|
|
|
|
return new RequestResult(true, user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false);
|
2024-08-10 15:36:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|