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

@@ -1,4 +1,5 @@
using HermesSocketLibrary.db;
using HermesSocketLibrary.Requests.Messages;
using HermesSocketServer.Messages;
using HermesSocketServer.Store.Internal;
@@ -7,14 +8,16 @@ namespace HermesSocketServer.Store
public class PolicyStore : AutoSavedStore<string, Policy>
{
private readonly string _userId;
private readonly IStore<string, Group> _groups;
private readonly Database _database;
private readonly Serilog.ILogger _logger;
public PolicyStore(string userId, DatabaseTable table, Database database, Serilog.ILogger logger)
public PolicyStore(string userId, DatabaseTable table, IStore<string, Group> groups, Database database, Serilog.ILogger logger)
: base(table, database, logger)
{
_userId = userId;
_groups = groups;
_database = database;
_logger = logger;
}
@@ -50,6 +53,9 @@ namespace HermesSocketServer.Store
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value.Span, nameof(value.Span));
ArgumentOutOfRangeException.ThrowIfLessThan(value.Span, 1000, nameof(value.Span));
ArgumentOutOfRangeException.ThrowIfGreaterThan(value.Span, 86400, nameof(value.Span));
if (_groups.Get(value.GroupId.ToString()) == null)
throw new ArgumentException("The group id does not exist.");
}
protected override void OnInitialModify(string key, Policy oldValue, Policy newValue)