Fixed multiple issues.
This commit is contained in:
parent
6176e6f3b9
commit
06bfe110bb
@ -19,9 +19,17 @@ namespace HermesSocketServer.Requests
|
|||||||
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
||||||
{
|
{
|
||||||
var channel = _channels.Get(sender);
|
var channel = _channels.Get(sender);
|
||||||
channel.Policies.Remove(data!["id"].ToString());
|
|
||||||
|
string policyId = data!["id"].ToString()!;
|
||||||
|
var policy = channel.Policies.Get(policyId);
|
||||||
|
if (policy != null) {
|
||||||
|
channel.Policies.Remove(policyId);
|
||||||
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
||||||
return RequestResult.Successful(null);
|
return RequestResult.Successful(policy.GroupId + "/" + policy.Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Warning("Failed to find policy by id ");
|
||||||
|
return RequestResult.Failed("Cannot find the policy by id.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ namespace HermesSocketServer.Socket.Handlers
|
|||||||
private readonly HashSet<string> _history;
|
private readonly HashSet<string> _history;
|
||||||
private readonly EmoteUsageMessage[] _array;
|
private readonly EmoteUsageMessage[] _array;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly object _lock;
|
||||||
|
|
||||||
private int _index;
|
private int _index;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ namespace HermesSocketServer.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_history = new HashSet<string>(101);
|
_history = new HashSet<string>(101);
|
||||||
_array = new EmoteUsageMessage[100];
|
_array = new EmoteUsageMessage[100];
|
||||||
|
_lock = new object();
|
||||||
_index = -1;
|
_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ namespace HermesSocketServer.Socket.Handlers
|
|||||||
if (message is not EmoteUsageMessage data || sender.Id == null)
|
if (message is not EmoteUsageMessage data || sender.Id == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (_logger)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (_history.Contains(data.MessageId))
|
if (_history.Contains(data.MessageId))
|
||||||
{
|
{
|
||||||
|
@ -77,6 +77,7 @@ namespace HermesSocketServer.Socket.Handlers
|
|||||||
var ack = new LoginAckMessage()
|
var ack = new LoginAckMessage()
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
|
SessionId = sender.UID,
|
||||||
OwnerId = _configuration.Tts.OwnerId,
|
OwnerId = _configuration.Tts.OwnerId,
|
||||||
Admin = sender.Admin,
|
Admin = sender.Admin,
|
||||||
WebLogin = data.WebLogin,
|
WebLogin = data.WebLogin,
|
||||||
|
@ -72,9 +72,9 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedInsertSql("TtsChatVoice", count, ["userId", "chatterId", "ttsVoiceId"]);
|
sql = _generator.GeneratePreparedInsertSql("TtsChatVoice", count, ["userId", "chatterId", "ttsVoiceId"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Adding {count} rows to database: {sql}");
|
_logger.Debug($"Chatter - Adding {count} rows to database: {sql}");
|
||||||
var values = list.Select(id => _store[id]).Where(v => v != null);
|
var values = list.Select(id => _store[id]).Where(v => v != null);
|
||||||
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
await _generator.DoPreparedStatement(_database, sql, values, ["userId", "chatterId", "ttsVoiceId"]);
|
||||||
}
|
}
|
||||||
if (_modified.Any())
|
if (_modified.Any())
|
||||||
{
|
{
|
||||||
@ -86,9 +86,9 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedUpdateSql("TtsChatVoice", count, ["userId", "chatterId"], ["ttsVoiceId"]);
|
sql = _generator.GeneratePreparedUpdateSql("TtsChatVoice", count, ["userId", "chatterId"], ["ttsVoiceId"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Modifying {count} rows in database: {sql}");
|
_logger.Debug($"Chatter - Modifying {count} rows in database: {sql}");
|
||||||
var values = list.Select(id => _store[id]).Where(v => v != null);
|
var values = list.Select(id => _store[id]).Where(v => v != null);
|
||||||
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
await _generator.DoPreparedStatement(_database, sql, values, ["userId", "chatterId", "ttsVoiceId"]);
|
||||||
}
|
}
|
||||||
if (_deleted.Any())
|
if (_deleted.Any())
|
||||||
{
|
{
|
||||||
@ -100,8 +100,8 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedDeleteSql("TtsChatVoice", count, ["userId", "chatterId"]);
|
sql = _generator.GeneratePreparedDeleteSql("TtsChatVoice", count, ["userId", "chatterId"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"Chatter - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list, ["userId", "chatterId"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedInsertSql("TtsVoice", count, ["id", "name"]);
|
sql = _generator.GeneratePreparedInsertSql("TtsVoice", count, ["id", "name"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Adding {count} rows to database: {sql}");
|
_logger.Debug($"Voice - Adding {count} rows to database: {sql}");
|
||||||
var values = list.Select(id => _store[id]).Where(v => v != null);
|
var values = list.Select(id => _store[id]).Where(v => v != null);
|
||||||
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedUpdateSql("TtsVoice", count, ["id"], ["name"]);
|
sql = _generator.GeneratePreparedUpdateSql("TtsVoice", count, ["id"], ["name"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Modifying {count} rows in database: {sql}");
|
_logger.Debug($"Voice - Modifying {count} rows in database: {sql}");
|
||||||
var values = list.Select(id => _store[id]).Where(v => v != null);
|
var values = list.Select(id => _store[id]).Where(v => v != null);
|
||||||
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
await _generator.DoPreparedStatement(_database, sql, values, ["id", "name", "email", "role", "ttsDefaultVoice"]);
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ namespace HermesSocketServer.Store
|
|||||||
count = list.Count;
|
count = list.Count;
|
||||||
sql = _generator.GeneratePreparedDeleteSql("TtsVoice", count, ["id"]);
|
sql = _generator.GeneratePreparedDeleteSql("TtsVoice", count, ["id"]);
|
||||||
|
|
||||||
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
|
_logger.Debug($"Voice - Deleting {count} rows from database: {sql}");
|
||||||
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
await _generator.DoPreparedStatementRaw(_database, sql, list, ["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user