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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user