Added checks for non-user foreign keys in stores. Load/Saving stores' order is now based on table dependencies. Added ability to use chat message when using redemption.

This commit is contained in:
Tom
2025-01-28 19:12:14 +00:00
parent 6d955f245a
commit 3e717522c2
18 changed files with 146 additions and 102 deletions

View File

@@ -23,7 +23,7 @@ namespace HermesSocketServer.Store
public override async Task Load()
{
var data = new Dictionary<string, object>() { { "user", _userId } };
string sql = $"SELECT name, type, data FROM \"Action\" WHERE \"userId\" = @user";
string sql = $"SELECT name, type, has_message, data FROM \"Action\" WHERE \"userId\" = @user";
await _database.Execute(sql, data, (reader) =>
{
var name = reader.GetString(0);
@@ -32,7 +32,8 @@ namespace HermesSocketServer.Store
UserId = _userId,
Name = name,
Type = reader.GetString(1),
Data = JsonSerializer.Deserialize<IDictionary<string, string>>(reader.GetString(2))!
HasMessage = reader.GetBoolean(2),
Data = JsonSerializer.Deserialize<IDictionary<string, string>>(reader.GetString(3))!
});
});
_logger.Information($"Loaded {_store.Count} redeemable actions from database.");