Fixed compiler warnings.
This commit is contained in:
@ -14,7 +14,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
string groupId = data["groupId"].ToString()!;
|
||||
@ -36,9 +36,9 @@ namespace HermesSocketServer.Requests
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Added policy to channel [policy id: {id}][group id: {groupId}][path: {path}][count: {count}][span: {span}][channel: {channel.Id}]");
|
||||
return RequestResult.Successful(policy);
|
||||
return Task.FromResult(RequestResult.Successful(policy));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
string search = data["search"].ToString()!;
|
||||
@ -33,9 +33,9 @@ namespace HermesSocketServer.Requests
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Added filter to channel [filter id: {id}][search: {search}][replace: {replace}][channel: {channel.Id}]");
|
||||
return RequestResult.Successful(filter);
|
||||
return Task.FromResult(RequestResult.Successful(filter));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace HermesSocketServer.Requests
|
||||
_random = new Random();
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string voice = data["voice"].ToString()!;
|
||||
string id = RandomString(25);
|
||||
@ -32,9 +32,9 @@ namespace HermesSocketServer.Requests
|
||||
|
||||
if (result) {
|
||||
_logger.Information($"Added a new voice [voice: {voice}][voice id: {id}]");
|
||||
return RequestResult.Successful(id);
|
||||
return Task.FromResult(RequestResult.Successful(id));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
|
||||
private string RandomString(int length)
|
||||
|
@ -14,18 +14,18 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string policyId = data["id"].ToString()!;
|
||||
var policy = channel.Policies.Get(policyId);
|
||||
if (policy != null) {
|
||||
channel.Policies.Remove(policyId);
|
||||
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
||||
return RequestResult.Successful(policy.GroupId + "/" + policy.Path);
|
||||
return Task.FromResult(RequestResult.Successful(policy.GroupId + "/" + policy.Path));
|
||||
}
|
||||
|
||||
_logger.Warning("Failed to find policy by id ");
|
||||
return RequestResult.Failed("Cannot find the policy by id.");
|
||||
_logger.Warning($"Failed to find policy by id [id: {policyId}]");
|
||||
return Task.FromResult(RequestResult.Failed("Cannot find the policy by id."));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,13 +14,13 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string filterId = data["id"].ToString()!;
|
||||
channel.Filters.Remove(filterId);
|
||||
|
||||
_logger.Information($"Deleted a TTS filter by id [tts filter id: {filterId}]");
|
||||
return RequestResult.Successful(null);
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
}
|
||||
}
|
@ -17,12 +17,12 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string voiceId = data["voice"].ToString()!;
|
||||
_voices.Remove(voiceId);
|
||||
_logger.Information($"Deleted a voice by id [voice id: {voiceId}]");
|
||||
return RequestResult.Successful(null);
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
IEnumerable<long> ids = channel.Chatters.Get().Values.Select(c => c.ChatterId);
|
||||
_logger.Information($"Fetched all chatters for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(ids, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(ids, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -19,13 +19,13 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var user = _users.Get(channel.Id);
|
||||
if (user == null)
|
||||
return RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Failed("Unable to find user data.", notifyClientsOnAccount: false));
|
||||
|
||||
return RequestResult.Successful(user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(user.DefaultVoice ?? _configuration.Tts.DefaultTtsVoice, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,12 +14,12 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var results = channel.Policies.Get().Values;
|
||||
|
||||
_logger.Information($"Fetched policies for channel [policy size: {results.Count}][channel: {channel.Id}]");
|
||||
return RequestResult.Successful(results, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(results, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,3 @@
|
||||
using System.Text.Json;
|
||||
using HermesSocketLibrary.db;
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using HermesSocketServer.Models;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
@ -10,31 +7,18 @@ namespace HermesSocketServer.Requests
|
||||
{
|
||||
public string Name => "get_redeemable_actions";
|
||||
public string[] RequiredKeys => [];
|
||||
private readonly JsonSerializerOptions _options;
|
||||
private readonly Database _database;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public GetRedeemableActions(JsonSerializerOptions options, Database database, ILogger logger)
|
||||
public GetRedeemableActions(ILogger logger)
|
||||
{
|
||||
_options = options;
|
||||
_database = database;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var temp = new Dictionary<string, object>() { { "user", channel.Id } };
|
||||
|
||||
var redemptions = new List<RedeemableAction>();
|
||||
string sql = $"SELECT name, type, data FROM \"Action\" WHERE \"userId\" = @user";
|
||||
await _database.Execute(sql, temp, (r) => redemptions.Add(new RedeemableAction()
|
||||
{
|
||||
Name = r.GetString(0),
|
||||
Type = r.GetString(1),
|
||||
Data = JsonSerializer.Deserialize<IDictionary<string, string>>(r.GetString(2), _options)!
|
||||
}));
|
||||
var redemptions = channel.Actions.Get().Values;
|
||||
_logger.Information($"Fetched all chatters' selected tts voice for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(redemptions, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(redemptions, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using HermesSocketLibrary.db;
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using HermesSocketServer.Models;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
@ -18,11 +17,11 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var temp = new Dictionary<string, object>() { { "user", channel.Id } };
|
||||
|
||||
var redemptions = new List<Redemption>();
|
||||
var redemptions = channel.Redemptions.Get().Values; /* new List<Redemption>();
|
||||
string sql = $"SELECT id, \"redemptionId\", \"actionName\", \"order\", state FROM \"Redemption\" WHERE \"userId\" = @user";
|
||||
await _database.Execute(sql, temp, (r) => redemptions.Add(new Redemption()
|
||||
{
|
||||
@ -31,9 +30,9 @@ namespace HermesSocketServer.Requests
|
||||
ActionName = r.GetString(2),
|
||||
Order = r.GetInt32(3),
|
||||
State = r.GetBoolean(4)
|
||||
}));
|
||||
}));*/
|
||||
_logger.Information($"Fetched all redemptions for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(redemptions, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(redemptions, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var results = channel.Chatters.Get().ToDictionary(p => p.Key, p => p.Value.VoiceId);
|
||||
_logger.Information($"Fetched all chatters' selected tts voice for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(results, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(results, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
IEnumerable<VoiceDetails> voices = _voices.Get().Select(v => new VoiceDetails()
|
||||
{
|
||||
@ -27,7 +27,7 @@ namespace HermesSocketServer.Requests
|
||||
});
|
||||
|
||||
_logger.Information($"Fetched all TTS voices for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(voices, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(voices, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -15,12 +15,12 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
IEnumerable<TTSWordFilter> filters = channel.Filters.Get().Values;
|
||||
|
||||
_logger.Information($"Fetched all word filters for channel [channel: {channel.Id}]");
|
||||
return RequestResult.Successful(filters, notifyClientsOnAccount: false);
|
||||
return Task.FromResult(RequestResult.Successful(filters, notifyClientsOnAccount: false));
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,6 @@ namespace HermesSocketServer.Requests
|
||||
string Name { get; }
|
||||
string[] RequiredKeys { get; }
|
||||
|
||||
Task<RequestResult> Grant(Channel channel, IDictionary<string, object>? data);
|
||||
Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace HermesSocketServer.Requests
|
||||
{
|
||||
if (message == null || message.Type == null)
|
||||
{
|
||||
_logger.Debug($"Request type does not exist [id: {message.RequestId}][nounce: {message.Nounce}]");
|
||||
_logger.Debug($"Request type does not exist [id: {message?.RequestId ?? "null"}][nounce: {message?.Nounce ?? "null"}]");
|
||||
return RequestResult.Failed("Request type does not exist.");
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ namespace HermesSocketServer.Requests
|
||||
|
||||
try
|
||||
{
|
||||
return await request.Grant(channel, message.Data);
|
||||
return await request.Grant(channel, message.Data ?? new Dictionary<string, object>());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -17,17 +17,17 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string user = data["user"].ToString()!;
|
||||
string voice = data["voice"].ToString()!;
|
||||
|
||||
var success = _users.Modify(user, (user) => user.DefaultVoice = voice);
|
||||
if (!success)
|
||||
return RequestResult.Failed("Unable to find user data.");
|
||||
return Task.FromResult(RequestResult.Failed("Unable to find user data."));
|
||||
|
||||
_logger.Information($"Updated default TTS voice for channel [channel: {channel.Id}][voice: {voice}]");
|
||||
return RequestResult.Successful(null);
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var id = Guid.Parse(data["id"].ToString()!);
|
||||
string groupId = data["groupId"].ToString()!;
|
||||
@ -36,9 +36,9 @@ namespace HermesSocketServer.Requests
|
||||
{
|
||||
var policy = channel.Policies.Get(id.ToString());
|
||||
_logger.Information($"Updated policy to channel [policy id: {id}][group id: {groupId}][path: {path}][count: {count}][span: {span}][channel: {channel.Id}]");
|
||||
return RequestResult.Successful(policy);
|
||||
return Task.FromResult(RequestResult.Successful(policy));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var id = data["id"].ToString()!;
|
||||
string search = data["search"].ToString()!;
|
||||
@ -35,9 +35,9 @@ namespace HermesSocketServer.Requests
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Updated filter to channel [filter id: {id}][search: {search}][replace: {replace}][channel: {channel.Id}]");
|
||||
return RequestResult.Successful(filter);
|
||||
return Task.FromResult(RequestResult.Successful(filter));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
string voiceName = data["voice"].ToString()!;
|
||||
string voiceId = data["voiceid"].ToString()!;
|
||||
@ -30,9 +30,9 @@ namespace HermesSocketServer.Requests
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Updated voice's [voice id: {voiceId}] name [new name: {voiceName}]");
|
||||
return RequestResult.Successful(null);
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace HermesSocketServer.Requests
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
data["voice"] = data["voice"].ToString();
|
||||
data["voice"] = data["voice"].ToString()!;
|
||||
data["state"] = data["state"].ToString() == "True";
|
||||
data["user"] = channel.Id;
|
||||
|
||||
|
Reference in New Issue
Block a user