hermes-server/Requests/GetDefaultTTSVoice.cs

30 lines
1.1 KiB
C#

using HermesSocketServer.Store;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class GetDefaultTTSVoice : IRequest
{
public string Name => "get_default_tts_voice";
public string[] RequiredKeys => [];
private readonly UserStore _users;
private readonly ServerConfiguration _configuration;
private readonly ILogger _logger;
public GetDefaultTTSVoice(UserStore users, ServerConfiguration configuration, ILogger logger)
{
_users = users;
_configuration = configuration;
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
var user = _users.Get(sender);
if (user == null)
return RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false);
return RequestResult.Successful(user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false);
}
}
}