Moved Requests classes to here. Added some checks to requests.

This commit is contained in:
Tom
2024-10-20 20:39:13 +00:00
parent a9cdb65895
commit e3c78d96fa
23 changed files with 186 additions and 150 deletions

View File

@@ -1,4 +1,3 @@
using HermesSocketLibrary.Requests;
using HermesSocketServer.Services;
using ILogger = Serilog.ILogger;
@@ -7,6 +6,7 @@ namespace HermesSocketServer.Requests
public class GetTTSUsers : IRequest
{
public string Name => "get_tts_users";
public string[] RequiredKeys => [];
private ChannelManager _channels;
private ILogger _logger;
@@ -19,12 +19,9 @@ namespace HermesSocketServer.Requests
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
var channel = _channels.Get(sender);
if (channel == null)
return new RequestResult(false, null, notifyClientsOnAccount: false);
var temp = channel.Chatters.Get().ToDictionary(p => p.Key, p => p.Value.VoiceId);
var results = channel.Chatters.Get().ToDictionary(p => p.Key, p => p.Value.VoiceId);
_logger.Information($"Fetched all chatters' selected tts voice for channel [channel: {sender}]");
return new RequestResult(true, temp, notifyClientsOnAccount: false);
return RequestResult.Successful(results, notifyClientsOnAccount: false);
}
}
}