Added database table data into configuration. Store saves is auto-handled. Added Action & Redemption stores.
This commit is contained in:
		| @@ -9,14 +9,16 @@ namespace HermesSocketServer.Services | ||||
|     { | ||||
|         private readonly UserStore _users; | ||||
|         private readonly Database _database; | ||||
|         private readonly ServerConfiguration _configuration; | ||||
|         private readonly Serilog.ILogger _logger; | ||||
|         private readonly IDictionary<string, Channel> _channels; | ||||
|         private readonly object _lock; | ||||
|  | ||||
|         public ChannelManager(UserStore users, Database database, Serilog.ILogger logger) | ||||
|         public ChannelManager(UserStore users, Database database, ServerConfiguration configuration, Serilog.ILogger logger) | ||||
|         { | ||||
|             _users = users; | ||||
|             _database = database; | ||||
|             _configuration = configuration; | ||||
|             _logger = logger; | ||||
|             _channels = new ConcurrentDictionary<string, Channel>(); | ||||
|             _lock = new object(); | ||||
| @@ -27,22 +29,25 @@ namespace HermesSocketServer.Services | ||||
|         { | ||||
|             var user = _users.Get(userId); | ||||
|             if (user == null) | ||||
|             { | ||||
|                 return Task.FromResult<Channel?>(null); | ||||
|             } | ||||
|  | ||||
|             lock (_lock) | ||||
|             { | ||||
|                 if (_channels.ContainsKey(userId)) | ||||
|                 { | ||||
|                     return Task.FromResult<Channel?>(null); | ||||
|                 } | ||||
|  | ||||
|                 var chatters = new ChatterStore(userId, _database, _logger); | ||||
|                 var policies = new PolicyStore(userId, _database, _logger); | ||||
|                 var filters = new TTSFilterStore(userId, _database, _logger); | ||||
|                 var actions = new ActionStore(userId, _database, _logger); | ||||
|                 var redemptions = new RedemptionStore(userId, _database, _logger); | ||||
|                  | ||||
|                 var actionTable = _configuration.Database.Tables["Action"]; | ||||
|                 var chatterTable = _configuration.Database.Tables["Chatter"]; | ||||
|                 var policyTable = _configuration.Database.Tables["Policy"]; | ||||
|                 var redemptionTable = _configuration.Database.Tables["Redemption"]; | ||||
|                 var ttsFilterTable = _configuration.Database.Tables["TtsFilter"]; | ||||
|  | ||||
|                 var chatters = new ChatterStore(userId, chatterTable, _database, _logger); | ||||
|                 var policies = new PolicyStore(userId, policyTable, _database, _logger); | ||||
|                 var filters = new TTSFilterStore(userId, ttsFilterTable, _database, _logger); | ||||
|                 var actions = new ActionStore(userId, actionTable, _database, _logger); | ||||
|                 var redemptions = new RedemptionStore(userId, redemptionTable, _database, _logger); | ||||
|  | ||||
|                 Task.WaitAll([ | ||||
|                     chatters.Load(), | ||||
|                     policies.Load(), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user