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 async Task Grant(string sender, IDictionary? data) { data["voice"] = data["voice"].ToString(); data["voiceid"] = data["voiceid"].ToString(); var result = _voices.Set(data["voiceid"].ToString(), new Voice() { Id = data["voiceid"].ToString()!, Name = data["voice"].ToString()! }); if (result) { _logger.Information($"Updated voice's [voice id: {data["voiceid"]}] name [new name: {data["voice"]}]"); return RequestResult.Successful(null); } return RequestResult.Failed("Something went wrong when updating the cache."); } } }