2024-08-10 19:36:32 +00:00
|
|
|
using HermesSocketLibrary.db;
|
2024-12-27 23:31:36 +00:00
|
|
|
using HermesSocketServer.Models;
|
2024-08-10 19:36:32 +00:00
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetRedemptions : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_redemptions";
|
2024-10-20 20:39:13 +00:00
|
|
|
public string[] RequiredKeys => [];
|
2024-08-10 19:36:32 +00:00
|
|
|
private readonly Database _database;
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
public GetRedemptions(Database database, ILogger logger)
|
|
|
|
{
|
|
|
|
_database = database;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-12-28 17:24:02 +00:00
|
|
|
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
2024-08-10 19:36:32 +00:00
|
|
|
{
|
2024-12-27 23:31:36 +00:00
|
|
|
var temp = new Dictionary<string, object>() { { "user", channel.Id } };
|
2024-08-10 19:36:32 +00:00
|
|
|
|
2024-12-28 17:24:02 +00:00
|
|
|
var redemptions = channel.Redemptions.Get().Values; /* new List<Redemption>();
|
2024-08-10 19:36:32 +00:00
|
|
|
string sql = $"SELECT id, \"redemptionId\", \"actionName\", \"order\", state FROM \"Redemption\" WHERE \"userId\" = @user";
|
|
|
|
await _database.Execute(sql, temp, (r) => redemptions.Add(new Redemption()
|
|
|
|
{
|
|
|
|
Id = r.GetGuid(0).ToString("D"),
|
|
|
|
RedemptionId = r.GetString(1),
|
|
|
|
ActionName = r.GetString(2),
|
|
|
|
Order = r.GetInt32(3),
|
|
|
|
State = r.GetBoolean(4)
|
2024-12-28 17:24:02 +00:00
|
|
|
}));*/
|
2024-12-27 23:31:36 +00:00
|
|
|
_logger.Information($"Fetched all redemptions for channel [channel: {channel.Id}]");
|
2024-12-28 17:24:02 +00:00
|
|
|
return Task.FromResult(RequestResult.Successful(redemptions, notifyClientsOnAccount: false));
|
2024-08-10 19:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|