using HermesSocketLibrary.db; using HermesSocketLibrary.Socket.Data; namespace HermesSocketServer.Requests { public class GetConnections : IRequest { public string Name => "get_connections"; public string[] RequiredKeys => []; private Database _database; private Serilog.ILogger _logger; public GetConnections(Database database, Serilog.ILogger logger) { _database = database; _logger = logger; } public async Task Grant(string sender, IDictionary? data) { var temp = new Dictionary() { { "user", sender } }; var connections = new List(); string sql = "select \"name\", \"type\", \"clientId\", \"accessToken\", \"grantType\", \"scope\", \"expiresAt\", \"default\" from \"Connection\" where \"userId\" = @user"; await _database.Execute(sql, temp, sql => connections.Add(new Connection() { Name = sql.GetString(0), Type = sql.GetString(1), ClientId = sql.GetString(2), AccessToken = sql.GetString(3), GrantType = sql.GetString(4), Scope = sql.GetString(5), ExpiresAt = sql.GetDateTime(6), Default = sql.GetBoolean(7) }) ); return RequestResult.Successful(connections, false); } } }