using HermesSocketServer.Store; using ILogger = Serilog.ILogger; namespace HermesSocketServer.Requests { public class UpdateDefaultTTSVoice : IRequest { public string Name => "update_default_tts_voice"; public string[] RequiredKeys => ["user", "voice"]; private UserStore _users; private ILogger _logger; public UpdateDefaultTTSVoice(UserStore users, ILogger logger) { _users = users; _logger = logger; } public async Task Grant(string sender, IDictionary? data) { data["user"] = data["user"].ToString(); data["voice"] = data["voice"].ToString(); var success = _users.Modify(data["user"].ToString(), (user) => user.DefaultVoice = data["voice"].ToString()!); if (!success) return RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false); _logger.Information($"Updated default TTS voice for channel [channel: {sender}][voice: {data["voice"]}]"); return RequestResult.Successful(null); } } }