using HermesSocketServer.Models; using HermesSocketServer.Store; using ILogger = Serilog.ILogger; namespace HermesSocketServer.Requests { public class UpdateTTSVoice : IRequest { public string Name => "update_tts_voice"; public string[] RequiredKeys => ["voice", "voiceId"]; private IStore _voices; private ILogger _logger; public UpdateTTSVoice(VoiceStore voices, ILogger logger) { _voices = voices; _logger = logger; } public Task Grant(Channel channel, IDictionary data) { string voiceName = data["voice"].ToString()!; string voiceId = data["voiceid"].ToString()!; var result = _voices.Set(voiceId, new Voice() { Id = voiceId, Name = voiceName }); if (result) { _logger.Information($"Updated voice's [voice id: {voiceId}] name [new name: {voiceName}]"); return Task.FromResult(RequestResult.Successful(null)); } return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache.")); } } }