hermes-server/Requests/GetDefaultTTSVoice.cs

30 lines
1.0 KiB
C#

using HermesSocketLibrary.Requests;
using HermesSocketServer.Store;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class GetDefaultTTSVoice : IRequest
{
public string Name => "get_default_tts_voice";
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 new RequestResult(false, "Unable to find user data.", notifyClientsOnAccount: false);
return new RequestResult(true, user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false);
}
}
}