Fixed multiple issues.

This commit is contained in:
Tom
2024-12-27 22:29:54 +00:00
parent 6176e6f3b9
commit 06bfe110bb
5 changed files with 24 additions and 13 deletions

View File

@ -19,9 +19,17 @@ namespace HermesSocketServer.Requests
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
var channel = _channels.Get(sender);
channel.Policies.Remove(data!["id"].ToString());
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
return RequestResult.Successful(null);
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"]}]");
return RequestResult.Successful(policy.GroupId + "/" + policy.Path);
}
_logger.Warning("Failed to find policy by id ");
return RequestResult.Failed("Cannot find the policy by id.");
}
}
}