2024-12-27 23:31:36 +00:00
|
|
|
using HermesSocketServer.Models;
|
2024-10-20 18:07:18 +00:00
|
|
|
using HermesSocketServer.Store;
|
2024-08-10 19:36:32 +00:00
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetDefaultTTSVoice : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_default_tts_voice";
|
2024-10-20 20:39:13 +00:00
|
|
|
public string[] RequiredKeys => [];
|
2024-10-20 18:07:18 +00:00
|
|
|
private readonly UserStore _users;
|
|
|
|
private readonly ServerConfiguration _configuration;
|
|
|
|
private readonly ILogger _logger;
|
2024-08-10 19:36:32 +00:00
|
|
|
|
2024-10-20 18:07:18 +00:00
|
|
|
public GetDefaultTTSVoice(UserStore users, ServerConfiguration configuration, ILogger logger)
|
2024-08-10 19:36:32 +00:00
|
|
|
{
|
2024-10-20 18:07:18 +00:00
|
|
|
_users = users;
|
|
|
|
_configuration = configuration;
|
2024-08-10 19:36:32 +00:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-12-27 23:31:36 +00:00
|
|
|
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
2024-08-10 19:36:32 +00:00
|
|
|
{
|
2024-12-27 23:31:36 +00:00
|
|
|
var user = _users.Get(channel.Id);
|
2024-10-20 18:07:18 +00:00
|
|
|
if (user == null)
|
2024-10-20 20:39:13 +00:00
|
|
|
return RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false);
|
2024-10-20 18:07:18 +00:00
|
|
|
|
2024-10-20 20:39:13 +00:00
|
|
|
return RequestResult.Successful(user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false);
|
2024-08-10 19:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|